I am trying to use the httpclient on android 1.6 and getting a 411
error. When I look at the wire I see the content-length header is being
set, but not right before the data. Would that cause the error, and if
so how do I fix it?
This is produced by http client and generated a 411 error.
HttpClient theHTTPClient = new DefaultHttpClient();
theHTTPClient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_0);
theHTTPClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
theHTTPPost = new
HttpPost("http://finance.google.com/finance/feeds/default/portfolios");
theHTTPPost.addHeader("Authorization", "GoogleLogin auth=" + theAuthToken);
theHTTPPost.addHeader("Content-Type", "application/atom+xml");
theHTTPPost.addHeader("Accept", "*/*");
theHTTPPost.addHeader("Connection", "close");
StringEntity theStringEntity = new StringEntity("<entry
xmlns='http://www.w3.org/2005/Atom'
xmlns:gf='http://schemas.google.com/finance/2007'> <title>Test2</title>
<gf:portfolioData currencyCode='USD'/> </entry>");
theStringEntity.setChunked(false);
theHTTPPost.setEntity(theStringEntity);
theHTTPResponse = theHTTPClient.execute(theHTTPPost);
WIRE DATA
9z0pEk@@J}_eUPMoZTPPOST /finance/feeds/default/portfolios HTTP/1.0
Authorization: GoogleLogin auth=[some data]
Content-Type: application/atom+xml
Accept: */*
Connection: close
Content-Length: 162
Host: finance.google.com
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gf='http://schemas.google.com/finance/2007'> <title>Test2</title>
<gf:portfolioData currencyCode='USD'/> </entry>
This is produced by curl and works!
curl -H "Authorization: GoogleLogin auth=some data" -H "Content-Type:
application/atom+xml" --data "<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gf='http://schemas.google.com/finance/2007'> <title>Test3</title>
<gf:portfolioData currencyCode='USD'/> </entry>"
"http://finance.google.com/finance/feeds/default/portfolios"
WIRE DATA
9z0pE@@&+J}_PcPvPOST /finance/feeds/default/portfolios HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7
OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Host: finance.google.com
Accept: */*
Authorization: GoogleLogin auth=[some data]
Content-Type: application/atom+xml
Content-Length: 162
<entry xmlns='http://www.w3.org/2005/Atom'
xmlns:gf='http://schemas.google.com/finance/2007'> <title>Test3</title>
<gf:portfolioData currencyCode='USD'/> </entry>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]