Hello all. Been scouring the forum and see many others have had similar problems but I've been unable to make any headway. I'm using the arduino web client example code to access a file on my web server using GET. I cannot make it to work as I only get "404 Not found" or "400 Bad request" errors. Here's my code :
char serverName[] = "www.hareti.co.uk";
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /test.txt HTTP/1.0\r\n");
client.println();
}
which results in :
HTTP/1.1 404 Not Found
404 Not Found
Date: Tue, 18 Dec 2012 21:23:25 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_bwlimited/1.4
Accept-Ranges: bytes
Connection: close
Content-Type: text/htmletc...
I've also tried :
char serverName[] = "www.hareti.co.uk";
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /test.txt HTTP/1.0\r\n");
client.println("Host: www.hareti.co.uk\r\n");
client.println();
}
but still only get a 404 not found error. I've tried changing the to HTTP 1.1 but this results in the following :
HTTP/1.1 400 Bad Request
400 Bad Request
Date: Tue, 18 Dec 2012 21:34:08 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_bwlimited/1.4
Content-Length: 376
Connection: close
Content-Type: text/html; charset=iso-8859-1
For two days I've been trying various combinations of HTTP versions, urls and "\n\r" with nothing but 404s and 400s. I've even installed a network traffic monitor on my PC to see how a web browser composes a request for the file but even copying this doesn't work. Chrome sends :
GET http://www.hareti.co.uk/test.txt HTTP/1.1
Host: www.hareti.co.uk
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: __utmz=125565075.1351194686.29.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none); PHPSESSID=963121c0a350be6962201519fb4fe1d0; __utma=125565075.1148824640.1316869956.1355782628.1355819117.31; __utmc=125565075
If-None-Match: "6cd00e0-20-4d12595427bc0"
If-Modified-Since: Tue, 18 Dec 2012 19:34:15 GMT
which returns the txt file perfectly. Changing my code to :
char serverName[] = "www.hareti.co.uk";
if (client.connect(serverName, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET http://www.hareti.co.uk/test.txt HTTP/1.1\r\n");
client.println("Host: www.hareti.co.uk\r\n");
client.println();
}
results in :
HTTP/1.1 400 Bad Request
400 Bad Request
Date: Tue, 18 Dec 2012 22:05:07 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_bwlimited/1.4
Content-Length: 371
Connection: close
Content-Type: text/html; charset=iso-8859-1
I can't figure out what I'm doing wrong. Does anyone have any suggestions?