Re: 'POST' method leads to 411 Length Required

2009-04-22 Thread Aaron Naiman
Dear Keary,

Thank you for getting back to me.

Some parts of the HTTP spec are ambiguous and left to implementation. In
 this specific case, error 411 means the server is saying that you are not
 sending a necessary content-length header, which is required for POSt
 requests whether there is any content or not. It may be that LWP doesn't
 provide the header if there is no content. Did you inspect the request to
 verify that the content-length header is indeed being sent?

 If the header is indeed being sent, the server might be choking on a 0
 length. Send bogus data to see if that helps.


Initially, I received www.google.com with GET, and 411 Length Required
with POST.

Subsequently, I tried providing header and content:

 $request = new HTTP::Request 'GET', 'http://www.google.com', [asdf =
'fdsa'], dummy content;

and now with GET I see: 411 Length Required, and with POST: 405 Method
Not Allowed.

So, I am pretty baffled as to what the rules are, and how I can make this
work.

Thanx,

Aaron

-- 
Aaron (Aharon) Naiman
Jerusalem College of Technology--Machon Lev
nai...@math.jct.ac.il
http://math.jct.ac.il/~naiman


RE: 'POST' method leads to 411 Length Required

2009-04-22 Thread Dirk-Willem van Gulik
Note that this 'expects' is fairly soft and does not go much further than 
Applications SHOULD use this field to indicate the transfer-length of the 
message-body, unless this is prohibited by the rules...  with the transmission 
rules (keep alive, chunked, etc) beeing the only exceptions overruling this for 
POST (and related). This has always* been a messy problem.

But in general - this is a client bug (it should have been a bit more strict in 
sending) - but arguably the server should (and can) be accomodating in what it 
accepts. So I would try to fix both sides - starting with your own. E.g. a 
simple content-length = $ENV{CONTENT_LENGTH} || 0 sort of thing :).

Thanks,

Dw.
*: 1998 http://arctic.org/~dean/apache/no-content-length/

 -Original Message-
 From: Bjoern Hoehrmann [mailto:derhoe...@gmx.net] 
 Sent: 21 April 2009 23:42
 To: Aaron Naiman
 Cc: libwww@perl.org
 Subject: Re: 'POST' method leads to 411 Length Required
 
 * Aaron Naiman wrote:
 $request = new HTTP::Request 'POST', 'http://www.google.com';
 
 $response = $ua-request($request);
 
 You are using POST but are not posting any data, and 
 apparently the server ...
 
 An Error Occurred 411 Length Required
 
 ... expects you to post some data when using POST.
 --
 Björn Höhrmann · mailto:bjo...@hoehrmann.de · 
 http://bjoern.hoehrmann.de Am Badedeich 7 · Telefon: 
 +49(0)160/4415681 · http://www.bjoernsworld.de
 25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · 
 http://www.websitedev.de/ 
 

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal 
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on 
it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.



Re: 'POST' method leads to 411 Length Required

2009-04-22 Thread Keary Suska

On Apr 22, 2009, at 3:11 AM, Aaron Naiman wrote:


Thank you for getting back to me.

Some parts of the HTTP spec are ambiguous and left to  
implementation. In
this specific case, error 411 means the server is saying that you  
are not

sending a necessary content-length header, which is required for POSt
requests whether there is any content or not. It may be that LWP  
doesn't
provide the header if there is no content. Did you inspect the  
request to

verify that the content-length header is indeed being sent?

If the header is indeed being sent, the server might be choking on  
a 0

length. Send bogus data to see if that helps.



Initially, I received www.google.com with GET, and 411 Length  
Required

with POST.

Subsequently, I tried providing header and content:

$request = new HTTP::Request 'GET', 'http://www.google.com',  
[asdf =

'fdsa'], dummy content;

and now with GET I see: 411 Length Required, and with POST: 405  
Method

Not Allowed.

So, I am pretty baffled as to what the rules are, and how I can make  
this

work.



I don't know about the first case, other than Google has been known to  
behave in nonstandard ways. a GET request shouldn't have an entity  
body, as I understand, and so shouldn't require a content length header.


The second case--405 method not allowed--just means the site doesn't  
permit a POST request. A server is not required to accept POSTs, so  
this response is possible.


It seems to me that the problems you are experiencing have more to do  
with your lack of understanding of the HTTP protocol, rather than the  
way LWP works. I suggest picking up a book on HTTP--I would recommend  
HTTP Developers Handbook by Chris Shiflett.


I would also underscore to not base your understanding on how google  
behaves. Historically Google has been unfriendly towards any  
interaction with their servers not performed by well known web  
browsing software.


Keary Suska



RE: 'POST' method leads to 411 Length Required

2009-04-22 Thread bruce
hey

i'm not sure of your favorite browser... but if it's firefox, i would
suggest you load a plugin called livehttpheaders (i think). this allows you
to see exactly what's happening between the browser/server so you can see
what's needed from the client side when you're attempting to create a client
to interface with the server

this process will tell you whether you're using get/post etc, and what the
server is expecting, sending back to the client...

you can also use a cmdline app like 'curl' to quickly see if what you think
is required, works.. once you get to this point, coding in perl/php/python
than becomes an easy process...


good luck!

-Original Message-
From: Keary Suska [mailto:hieroph...@pcisys.net]
Sent: Wednesday, April 22, 2009 7:16 AM
To: Aaron Naiman
Cc: Libwww Perl
Subject: Re: 'POST' method leads to 411 Length Required


On Apr 22, 2009, at 3:11 AM, Aaron Naiman wrote:

 Thank you for getting back to me.

 Some parts of the HTTP spec are ambiguous and left to
 implementation. In
 this specific case, error 411 means the server is saying that you
 are not
 sending a necessary content-length header, which is required for POSt
 requests whether there is any content or not. It may be that LWP
 doesn't
 provide the header if there is no content. Did you inspect the
 request to
 verify that the content-length header is indeed being sent?

 If the header is indeed being sent, the server might be choking on
 a 0
 length. Send bogus data to see if that helps.


 Initially, I received www.google.com with GET, and 411 Length
 Required
 with POST.

 Subsequently, I tried providing header and content:

 $request = new HTTP::Request 'GET', 'http://www.google.com',
 [asdf =
 'fdsa'], dummy content;

 and now with GET I see: 411 Length Required, and with POST: 405
 Method
 Not Allowed.

 So, I am pretty baffled as to what the rules are, and how I can make
 this
 work.


I don't know about the first case, other than Google has been known to
behave in nonstandard ways. a GET request shouldn't have an entity
body, as I understand, and so shouldn't require a content length header.

The second case--405 method not allowed--just means the site doesn't
permit a POST request. A server is not required to accept POSTs, so
this response is possible.

It seems to me that the problems you are experiencing have more to do
with your lack of understanding of the HTTP protocol, rather than the
way LWP works. I suggest picking up a book on HTTP--I would recommend
HTTP Developers Handbook by Chris Shiflett.

I would also underscore to not base your understanding on how google
behaves. Historically Google has been unfriendly towards any
interaction with their servers not performed by well known web
browsing software.

Keary Suska



Re: 'POST' method leads to 411 Length Required

2009-04-21 Thread Bjoern Hoehrmann
* Aaron Naiman wrote:
$request = new HTTP::Request 'POST', 'http://www.google.com';

$response = $ua-request($request);

You are using POST but are not posting any data, and apparently the
server ...

An Error Occurred 411 Length Required

... expects you to post some data when using POST.
-- 
Björn Höhrmann · mailto:bjo...@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 


Re: 'POST' method leads to 411 Length Required

2009-04-21 Thread Aaron Naiman
Dear Björn,

Thank you for the quick result.

* Aaron Naiman wrote:
 $request = new HTTP::Request 'POST', 'http://www.google.com';
 
 $response = $ua-request($request);

 You are using POST but are not posting any data, and apparently the
 server ...

 An Error Occurred 411 Length Required

 ... expects you to post some data when using POST.


But as can be seen from .../HTTP/Status.pm, this is a *client* error, and
not a server error.

Still stuck, 

Thanx,

Aaron

-- 
Aaron (Aharon) Naiman
Jerusalem College of Technology--Machon Lev
nai...@math.jct.ac.il
http://math.jct.ac.il/~naiman


Re: 'POST' method leads to 411 Length Required

2009-04-21 Thread Aaron Naiman
Dear Björn,

Thank you again for your response.

* Aaron Naiman wrote:
  You are using POST but are not posting any data, and apparently the
  server ...
 
  An Error Occurred 411 Length Required
 
  ... expects you to post some data when using POST.
 
 But as can be seen from .../HTTP/Status.pm, this is a *client* error, and
 not a server error.

 You're sending somebody who expects a letter from you an empty envelope.


However, from all of the examples I have seen, one need not send anything in
a POST.

The only difference between GET and POST, is that the former sends the
parameters in the URL, and the latter, as part of the header.  N'est pas?

Anyhow, I have tried sending header and content, and still get the same
error.

Were you able to succeed with sending content (filling in the envelope), and
using the POST method?

Thanx,

Aaron

-- 
Aaron (Aharon) Naiman
Jerusalem College of Technology--Machon Lev
nai...@math.jct.ac.il
http://math.jct.ac.il/~naiman


Re: 'POST' method leads to 411 Length Required

2009-04-21 Thread Keary Suska

On Apr 21, 2009, at 5:10 PM, Aaron Naiman wrote:


Dear Björn,

Thank you again for your response.

* Aaron Naiman wrote:

You are using POST but are not posting any data, and apparently the
server ...


An Error Occurred 411 Length Required


... expects you to post some data when using POST.


But as can be seen from .../HTTP/Status.pm, this is a *client*  
error, and

not a server error.


You're sending somebody who expects a letter from you an empty  
envelope.



However, from all of the examples I have seen, one need not send  
anything in

a POST.


Some parts of the HTTP spec are ambiguous and left to implementation.  
In this specific case, error 411 means the server is saying that you  
are not sending a necessary content-length header, which is required  
for POSt requests whether there is any content or not. It may be that  
LWP doesn't provide the header if there is no content. Did you inspect  
the request to verify that the content-length header is indeed being  
sent?


If the header is indeed being sent, the server might be choking on a 0  
length. Send bogus data to see if that helps.


HTH,

Keary Suska