hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Miller <glenmil...@skyviewsoftware.com>
Subject Re: 411 Length Required
Date Thu, 29 Jul 2010 13:54:35 GMT
Ignore the previous email.  That was it, there is a cr/lf on the end of
the auth string!  Got it working now thanks.

On 07/28/2010 07:59 AM, David Motes wrote:
> Is there really a blank line after the "Authorization: GoogleLogin
> auth=[some data]" ?
> That would indicate the end of the headers.
> Do you need to strip CR-LF from the google auth data?
> Why are you setting it to HTTP 1.0?
> 
> 
> 
> On Wed, Jul 28, 2010 at 12:26 AM, Glen Miller
> <glenmiller@skyviewsoftware.com> wrote:
>> 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: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message