Hello friends,
i've the requirement to send some params to a target url.
Before start i've debugged the communication betw. my browser & the target
url using HTTP-Sniffer.
HTTP-Sniffer-LOG (after sending an initial GET): [the param ("theVar") of
interest, which i always get from the GET is in the line before the POST
starts,
later, when the browser (appl.) sends it, it is marked red/bold]
############################################################################
##########################
status=OK&theVar=8e664b1e3914f78905e87a20cc41ef3b
POST /auth/mysite HTTP/1.1
Accept: */*
Accept-Language: de-DE
Referer: http://www.mytarget.com/mysite.jspx
x-flash-version: 10,0,45,2
Content-Type: application/x-www-form-urlencoded
Content-Length: 115
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0;
InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648;
.NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Host: www.mytarget.com
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: PHPSESSID=2054d4ebc2b0e564d8cdf98c0e6774ed
password=myPW&theVar=8e664b1e3914f78905e87a20cc41ef3b&session=1275694569014&
email=myEmailEtc
HTTP/1.1 200 OK
Date: Fri, 04 Jun 2010 23:36:06 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch
mod_ssl/2.2.9 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.6-1+lenny8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
Pragma: no-cache
Set-Cookie: puk=VR_5228; expires=Mon, 30-May-2011 23:36:06 GMT; path=/
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 64
Keep-Alive: timeout=15, max=91
Connection: Keep-Alive
Content-Type: text/html
############################################################################
##########################
>From this IE-LOG i've assumed, that the line
"password=myPW&theVar=8e664b1e3914f78905e87a20cc41ef3b&session=1275694569014
&email=myEmailEtc"
can be generated with the below mentioned source (ArrayList<NameValuePair>()
etc.).
And now my programm (Debug-LOG): (I've reduced it to lines of interest &
have shortened the beginning of each line)
############################################################################
##########################
headers: >> POST /auth/mysite HTTP/1.1
headers: >> Host: www.mytarget.com
headers: >> User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
Trident/4.0; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR
3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR
3.5.30729)
headers: >> Accept: */*
headers: >> Accept-Language: de-DE
headers: >> Referer: http://www.mytarget.com/mysite.jspx
headers: >> Keep-Alive: 115
headers: >> Connection: Keep-Alive
headers: >> Content-type: application/x-www-form-urlencoded
headers: >> Cache-Control: no-cache
headers: >> Content-Length: 117
headers: >> Expect: 100-Continue
wire: << "HTTP/1.1 100 Continue[EOL]"
wire: << "[EOL]"
impl.conn.DefaultClientConnection: Receiving response: HTTP/1.1 100 Continue
headers: << HTTP/1.1 100 Continue
wire: >>
"password=myPW&theVar=8e664b1e3914f78905e87a20cc41ef3b&session=1275694569014
&email=myEmailEtc"
wire: << "HTTP/1.1 200 OK[EOL]"
wire: << "Date: Sun, 06 Jun 2010 13:40:11 GMT[EOL]"
############################################################################
##########################
As you can see, i'm sending the params, including the "theVar", but i always
get an error message, that this param has not been received by the target
URL.
The params are added programmatically with the following source:
############################################################################
###############################################
List<NameValuePair> qparams = new ArrayList<NameValuePair>();
qparams.add(new BasicNameValuePair("password", password));
qparams.add(new BasicNameValuePair("theVar", theVar));
// qparams.add(new BasicNameValuePair("session",
Long.toString(session)));
qparams.add(new BasicNameValuePair("session", mySession));
qparams.add(new BasicNameValuePair("email", eMail));
URI uri = null;
HttpPost httppost = null;
UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(qparams,
HTTP.UTF_8);
try {
// uri = URIUtils.createURI("http", "www.mytarget.com", -1,
"/auth/mysite", URLEncodedUtils.format(qparams, "UTF-8"), null);
uri = URIUtils.createURI("http", "www.mytarget.com", -1, "/auth/mysite",
null, null);
httppost = new HttpPost(uri);
setDataInPostHeader(httppost);
httppost.setEntity(postEntity);
HttpResponse loginResponse = httpclient.execute(httppost, localContext);
############################################################################
################################################
Please, can anyone support me or give me a hint ? Could it have anything
todo with the headers ? I've a method, where i ensure, that the header is
the same.
Any help would be greatful.
Thanks.
D.