c# - What's wrong with my HttpWebRequest POST Request -
i have trouble while sending post
http packages website, in sniffer looks http://data2.floomby.com/files/previews/25_3_2013/kui91gedh02qmem94lqtw.jpg @ screenshot. think, mixing post content data before sends, postdata
string looks normal. here method code:
public responsedata advancedrequest(string method, string url, string postdata, string proxydata, string referer, int timeout) { var req = webrequest.create(url) httpwebrequest; req.method = "get"; iwebproxy myproxy = new webproxy(proxydata.split(':')[0], convert.toint32(proxydata.split(':')[1])); req.proxy = null; //req.servicepoint.connectionlimit = 1; req.protocolversion = httpversion.version10; req.keepalive = true; //req.useragent = "mozilla/5.0 (windows nt 6.1; wow64; rv:19.0) gecko/20100101 firefox/19.0"; req.useragent = "mozilla/5.0 (windows nt 6.1; wow64; rv:19.0) gecko/20100101 firefox/19.0"; req.allowautoredirect = false; req.timeout = timeout*1000; req.readwritetimeout = timeout*1000; req.contenttype = "application/x-www-form-urlencoded"; req.accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; req.headers.add("accept-language", "en-us,en;q=0.5"); //req.headers.add("accept-charset", "iso-8859-1,utf-8;q=0.7,*;q=0.3"); req.headers.add("accept-encoding", "gzip, deflate"); //req.headers.add("cache-control", "max-age=0"); req.cookiecontainer = _cookies; //req.headers.add("keep-alive", "115"); //req.connection = "keepalive"; if (!string.isnullorempty(referer)) { req.referer = referer; } req.automaticdecompression = decompressionmethods.gzip | decompressionmethods.deflate; if (method == "post") { req.method = "post"; req.servicepoint.expect100continue = false; system.text.encoding enc = system.text.encoding.utf8; var bytedata = enc.getbytes(postdata); req.contentlength = bytedata.length; //stream poststream = req.getrequeststream(); try { using (var poststream = req.getrequeststream()) { poststream.write(bytedata, 0, bytedata.length); poststream.close(); } } catch (webexception except) { } } httpwebresponse resp = (httpwebresponse)req.getresponse() httpwebresponse; this._cookies.add(resp.cookies); //resp.close(); responsedata rdata = new responsedata(resp); resp.close(); return rdata; //streamreader strdr = new streamreader(resp.getresponsestream()); //string response = strdr.readtoend(); //strdr.close(); //return response; }
here right post data:
session%5busername_or_email%5d=loginhere&session%5bpassword%5d=passwordhere&return_to_ssl=true&scribe_log=&redirect_after_login=%2f&authenticity_token=auth_token_here
here wrong post data have:
session%5busername_or_email%5d=asynccallback&session%5bpassword%5d=de2zmcc6093&return_to_ssl=true&scribe_log=&redirect_after_login=%2f&authenticity_token=0e67f8df715c79f81a9b2be203848ad7f805b21csession%5busername_or_email%5d=asynccallback&session%5bpassword%5d=de2zmcc6093&return_to_ssl=true&scribe_log=&redirect_after_login=%2f&authenticity_token=0e67f8df715c79f81a9b2be203848ad7f805b21c
the value of postdata
is:
session%5busername_or_email%5d=login&session%5bpassword%5d=password&return_to_ssl=true&scribe_log=&redirect_after_login=%2f&authenticity_token=0e67f8df715c79f81a9b2be203848ad7f805b21c
Comments
Post a Comment