Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Welcome to the Monastery
 
PerlMonks  

Should LWP warn about wrong Content-Length?

by vsespb (Hermit)
on May 30, 2013 at 06:50 UTC ( #1035977=perlquestion: print w/ replies, xml ) Need Help??
vsespb has asked for the wisdom of the Perl Monks concerning the following question:

If I run
nc -l 9903
And then run LWP and paste something like this into "nc" window
HTTP/1.1 200 OK Content-Length: 133 LNJKjadfkj ^C
I will get in 'lwp' window:
GET -S -e http://localhost:9903/ GET http://localhost:9903/ --> 200 OK Content-Length: 133 Client-Date: Thu, 30 May 2013 06:41:09 GMT Client-Peer: 127.0.0.1:9903 Client-Response-Num: 1 LNJKjadfkj
So it's detected as success request. But tools like curl/wget report this as error/warning or even retry.
And according to RFC http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 Content-Length is priority over connecion close.
When a message-body is included with a message, the transfer-length of that body is determined by one of the following (in order of precedence):
...
3. If a Content-Length header field (section 14.13) is present, its decimal value in OCTETs represents both the entity-length and the transfer-length
...
5.By the server closing the connection.
Am I missing something?
UPD
So, not sure if this intended behaviour or no, so I reported a bug https://rt.cpan.org/Public/Bug/Display.html?id=85759

Comment on Should LWP warn about wrong Content-Length?
Select or Download Code
Re: Should LWP warn about wrong Content-Length? (it does)
by Anonymous Monk on May 30, 2013 at 08:09 UTC
      warn "Content-Length header value was wrong, fixed"; warn "Content-Length set when there is no content, fixed";
      I saw this code, but looks like it's request headers, not response header. Besides in my example, there is no warnings.
      'GET' implies very old version of LWP
      GET just uses last version of LWP, installed on the box. No?
      Also I actually experience this behaviour in my normal code, without GET tool.

        I saw this code, but looks like it's request headers, not response header. Besides in my example, there is no warnings.

        Well :) now you know your next course of action, submit a bug report if you think its important

        OTOH, a warning seems like a clumsy way to communicate this -- sure its better than nothing, but not by much

        GET just uses last version of LWP, installed on the box. No?

        I think so yeah, but its not installed by default anymore ... which version do you have, the latest available?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1035977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2014-04-20 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls