Bug #1351

lighttpd returns "400 Bad Request" for Nokia web browser request

Added by Anonymous over 6 years ago. Updated almost 4 years ago.

Status:DuplicateStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:core
Target version:-
Missing in 1.5.x:No

Description

We are running http://m.nokaut.pl/ mobile price comparison website on lighttpd 1.5-svn.

Everything works OK with popular browsers, Opera Mobile and some built-in mobile browsers (eg. Motorola, Samsung), but there is a MAJOR problem with all the requests from Nokia built-in web browser. All such requests receive "HTTP/1.1 400 Bad Request" error. I guess that it is caused by some not-standard HTTP headers.

Here is the full connection log (sniffed by ettercap):

-- michal.jaskolski


Related issues

Duplicates Bug #1717: Google's urlfetch from appEngine and lighttpd HTTP 400 re... Patch Pending

History

#1 Updated by Anonymous over 6 years ago

From what I can see, the problem is that your browser sends a Content-Length header during a GET request. (GET requests cannot contain a message-body; according to RFC2068 the Content-Length header signals that a message-body follows)

Lines 542-545 of request.c:


    case HTTP_METHOD_GET:
    case HTTP_METHOD_HEAD:
        /* content-length is forbidden for those */
        if (con->request.content_length != -1) {

I guess you could change it to something like this, to be more lenient.


        if (con->request.content_length <= 0) {

#2 Updated by Anonymous over 6 years ago

(That should be a > instead of a <=, sorry)

#3 Updated by Anonymous over 6 years ago

After changing that line, everything works well. We will contact Nokia and ask them to change their software to be RFC-compatible, but I think that the patch above should be included in main lighttpd source.

-- michal.jaskolski

#4 Updated by Anonymous over 6 years ago

The same RFC incompatibility exists with the popular PHP SOAP library, nuSOAP. Here is a fix if anyone finds this page while trying to figure out the 400 errors with nuSOAP, like me :)

http://sourceforge.net/mailarchive/forum.php?thread_name=4d3038af0711281419l17a80a91xffce31ff20af873a%40mail.gmail.com&forum_name=nusoap-general

-- raj

#5 Updated by Anonymous almost 6 years ago

Also occurs on some Motorola phones

#6 Updated by Anonymous over 5 years ago

Well the above solution is inappropriate better would be something like this solution below. Some HTTP client libraries send a content-length = 0 which is somehow in line with the RFC. Its just a question of the interpretation. Apache deals with it in the same way.


if (con->request.content_length != 1 && con->request.content_length != 0) {

-- thomas.nicolai

#7 Updated by Anonymous over 5 years ago

Sorry thats the right one

if (con->request.content_length != -1 && con->request.content_length != 0) {

Replying to thomas.nicolai@…:

Well the above solution is inappropriate better would be something like this solution below. Some HTTP client libraries send a content-length = 0 which is somehow in line with the RFC. Its just a question of the interpretation. Apache deals with it in the same way.

{{{
if (con->request.content_length != 1 && con->request.content_length != 0) {
}}}

#8 Updated by stbuehler almost 4 years ago

  • Status changed from New to Duplicate
  • Assignee deleted (jan)
  • Priority changed from High to Normal
  • Target version deleted (1.5.0)
  • Missing in 1.5.x set to No

Also available in: Atom