I’m using the same URL code to POST data to my web application, it’s a simple JSON data post. On windows and MAC i’m getting the right answers from my server, but when on Linux the same post produces an error from the server, i wanted to see how the request looks like and i got:
POST /ddb/ HTTP/1.0
Host: ctrlr.org:80
User-Agent: JUCE/2.0
Connection: Close
Content-Length: 69
Content-Type: application/x-www-form-urlencoded
Content-length: 69
requestData=%5b%0d%0a++%22__list%22%2c%0d%0a++%22allItems%22%0d%0a%5d
with that, the response from the server is “HTTP Error 413 Request entity too large”
well yeah that response is very weird, i don’t know if that has to do with the double Content-length header, i was stumped cause it all works on other platforms.
Well that removed the duplicate but did not help. I decided to go deep with Wireshark and compared Windows and Linux request headers from my application (same build)
on Linux i get
POST /ddb/ HTTP/1.0
Host: ctrlr.org:80
User-Agent: JUCE/2.0
Connection: Close
Content-Type: application/x-www-form-urlencoded
Content-length: 69
requestData=%5b%0d%0a++%22__list%22%2c%0d%0a++%22allItems%22%0d%0a%5dHTTP/1.1 200 OK
Server: Apache/2.2.3 (CentOS)
Last-Modified: Thu, 15 Jul 2010 18:08:10 GMT
ETag: "13f-48b70fc293680"
Accept-Ranges: bytes
Cache-Control: max-age=172800
Expires: Sat, 10 Sep 2011 19:12:15 GMT
Content-Type: text/html
Content-Length: 319
Date: Thu, 08 Sep 2011 19:12:15 GMT
X-Varnish: 654761406
Age: 0
Via: 1.1 varnish
Connection: close
<html>
<head>
<title>Unknown Site</title>
</head>
<body>
<p>This space is managed by SourceForge.net. You have attempted to access a URL that either never existed or is no longer active. Please check the source of your link and/or contact the maintainer of the link to have them update their records.
</body>
</html>
So the request looks OK but the response is bad (since the site exists and is fine)
And comparing the two i removed the port from the Host: header on Linux and it worked. I don’t know the “exact” specs for HTTP but i think you specify the port if you are requesting a virtualHost on a perticular port, otherwise any HTTP server (apache, or varnish in this case witch is a reverse proxy) will lookup a invalid virtual name for that host.
Anyway on line 353 in linux_Network.cpp i changed from
First, the decomposeUrl method return the default port as 0
then 0 is used as a service port with a call to getaddrinfo()
result from getaddrinfo() is passed to connect() and connect() fails, since the port is 0 (and not NULL, from what i’ve seen getaddrinfo() can deal without the port, also i think the returned data is a linked list maybe it would be a good idea, to iterate through it and try to connect to any of the results ? http://en.wikipedia.org/wiki/Getaddrinfo)
If i tried setting the port to 80 as the deaful in the decomposeURL then the request fails because the method createRequesHeader adds the port number to the Host header (and the source url does not have the port in it, so it’s an invalid request)
I thought it might be best to include the port in the Host header only if the passed URL contains the port specification otherwise, lookup the port and pass it to the socket but never use it in the Host header.