Ticket #1351 (new defect)

Opened 10 months ago

Last modified 1 month ago

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

Reported by: michal.jaskolski@nokaut.pl Assigned to: jan
Priority: high Milestone: 1.5.0
Component: core Version: 1.5.x-svn
Severity: critical Keywords: nokia xhtml wap series60
Cc: Blocking:
Need Feedback: 0

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):

GET / HTTP/1.1.                                                                                                                                        
Host: m.nokaut.pl.                                                                                                                                     
Cache-Control: no-cache.                                                                                                                               
Pragma: no-cache.                                                                                                                                      
Accept: text/javascript, text/ecmascript, application/x-javascript, text/html, application/vnd.wap.xhtml+xml, application/xhtml+xml, text/css, multipar
t/mixed, text/vnd.wap.wml, application/vnd.wap.wmlc, application/vnd.wap.wmlscriptc, application/java-archive, application/java, application/x-java-arc
hive, text/vnd.sun.j2me.app-descriptor, application/vnd.oma.drm.message, application/vnd.oma.drm.content, application/vnd.wap.mms-message, application/
vnd.wap.sic, text/x-co-desc, application/vnd.oma.dd+xml, text/javascript, */*, text/x-vcard, text/x-vcalendar, image/gif, image/vnd.wap.wbmp.          
Accept-Charset: iso-8859-1, utf-8, iso-10646-ucs-2; q=0.6.                                                                                             
Accept-Encoding: gzip,deflate,identity;q=0.9.                                                                                                          
Accept-Language: pl.                                                                                                                                   
User-Agent: NokiaN70-1/5.0638.3.0.1 Series60/2.8 Profile/MIDP-2.0 Configuration/CLDC-1.1.                                                              
x-wap-profile: "http://nds1.nds.nokia.com/uaprof/NN70-1r100.xml".                                                                                      
Content-length: 0.                                                                                                                                     
Via: WTP/1.1 nwg2 (Nokia WAP Gateway 4.1/CD15/4.1.93).                                                                                                 
X-Network-info: GPRS,unsecured.                                                                                                                        
X-Nokia-CONNECTION_MODE: TCP.                                                                                                                          
X-Nokia-BEARER: GPRS.                                                                                                                                  
X-Nokia-GATEWAY_ID: NWG/4.1/Build93.                                                                                                                   
x-nokia.wia.accept.original: text/javascript,text/ecmascript,application/x-javascript,text/html,application/vnd.wap.xhtml+xml,application/xhtml+xml,tex
t/css,multipart/mixed,text/vnd.wap.wml,application/vnd.wap.wmlc,application/vnd.wap.wmlscriptc,application/java-archive,application/java,application/x-
java-archive,text/vnd.sun.j2me.app-descriptor,application/vnd.oma.drm.message,application/vnd.oma.drm.content,application/vnd.wap.mms-message,applicati
on/vnd.wap.sic,text/x-co-desc,application/vnd.oma.dd+xml,text/javascript,*/*,text/x-vCard,text/x-vCalendar,image/gif,image/vnd.wap.wbmp.               
Connection: close.                                                                                                                                     
.                                                                                                                                                      
HTTP/1.1 400 Bad Request.                                                                                                                              
Content-Type: text/html.                                                                                                                               
Vary: Accept-Encoding.                                                                                                                                 
Content-Encoding: gzip.                                                                                                                                
Content-Length: 248.                                                                                                                                   
Connection: close.                                                                                                                                     
Date: Mon, 10 Sep 2007 15:15:03 GMT.                                                                                                                   
Server: lighttpd/1.5.0.                                                                                                                                
.                                                                                                                                                      
..........m.QO. ....+...[2M..v..%.L]....BV.                                                                                                            
Z.../...0^..p...|yx..K..8[.....}u..}E.wt>.*)#.:...}#..k.B4m.V....E|.5..h..Z.n R@..z."U...;...!]....q..q..a.b...e.rji...UP$F8..#[_....,'7I.E/........x..
..x0...eQ...T........C..I._..>z:v..o.zR.1F....0X!]... 

Attachments

Change History

09/10/2007 08:41:21 PM changed by anonymous

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) {

09/10/2007 08:45:56 PM changed by anonymous

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

09/14/2007 05:27:02 PM changed by michal.jaskolski@nokaut.pl

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.

11/28/2007 10:32:14 PM changed by raj@aonic.net

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

05/30/2008 12:44:02 AM changed by anonymous

Also occurs on some Motorola phones


Add/Change #1351 (lighttpd returns "400 Bad Request" for Nokia web browser request)




Change Properties