java - Login to site with HttpClient Post -
i trying make program logs site , performs automated activities. have been using httpclient 4.0.1, , using started: http://hc.apache.org/httpcomponents-client/primer.html.
on particular site, cookies not set through "set-cookie" header, in javascript.
so far, unable achieve login.
i've tried following things:
- add headers manually request headers appear in firebug
namevaluepair[] data = { new basicnamevaluepair("host",host), new basicnamevaluepair("user-agent"," mozilla/5.0 (macintosh; u; intel mac os x 10.5; en-us; rv:1.9.1.7) gecko/20091221 firefox/3.5.7"), new basicnamevaluepair("accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), new basicnamevaluepair("accept-language","en-us,en;q=0.5"), new basicnamevaluepair("accept-encoding","gzip,deflate"), new basicnamevaluepair("accept-charset","iso-8859-1,utf-8;q=0.7,*;q=0.7"), new basicnamevaluepair("keep-alive","300"), new basicnamevaluepair("connection","keep-alive"), new basicnamevaluepair("referer",referer), new basicnamevaluepair("cookie",cookiestr) }; for(namevaluepair pair : data){ loginpost.addheader(pair.getname(),pair.getvalue()); }
- creating basicclientcookies , setting using setcookiestore. unfortunately, can't figure out how test if cookies being sent. also, there way test other automatic parameters being sent? (like browser being emulated, etc).
the response i'm getting is: http/1.1 417 expectation failed
i'm still new this, know off-hand problem be? if not, i'll post more details, code, , site.
you need wireshark or fiddler. first network analyser (so you'll see what's going on @ low level); second acts proxy - less transparent, higher level.
that way can in detail @ happens when log in browser, , what's happening when try doing same thing in code.
Comments
Post a Comment