You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Glen Miller <gl...@skyviewsoftware.com> on 2010/07/28 06:26:15 UTC
411 Length Required
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
Re: 411 Length Required
Posted by Glen Miller <gl...@skyviewsoftware.com>.
No there is not a blank line, but there is something different between
the 2 wireshark shows 2 sections for the org.apache call, and only 1 for
the curl.
There is no CR-LF on the auth data.
I have tried both HTTP 1.1 and HTTP 1.0, HTTP 1.0 just happened to be
last one I tried before sending out a message asking for help.
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
> <gl...@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
Re: 411 Length Required
Posted by Glen Miller <gl...@skyviewsoftware.com>.
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
> <gl...@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
Re: 411 Length Required
Posted by David Motes <da...@gmail.com>.
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
<gl...@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