Welcome Guest, Not a member yet? Register   Sign In
Minimum GET request?
#1

[eluser]liamstask[/eluser]
Hiya - I'm just starting up with CI and enjoying it so far.

I'm creating an app that, at least partially, will accept HTTP connections from embedded devices (ie, not web browsers) and am wondering what the minimum info I'll need to provide with the request is. I ask because I fired up a simple script that connects (sucessfully), sends a "GET / HTTP 1.1\n" but receives nothing in response, whereas the page pops up in my browser no problem. The same request to other web pages returns the HTML page as expected. I get a similar result when trying to manually POST anything, like

Code:
write("POST /mycontroller \r\nContent-Type: text/plain\r\nContent-Length: 7\r\n\r\n");
write("test=23");

Any ideas what would prevent this from reading back from my CI installation?

Thanks!
#2

[eluser]DerekF[/eluser]
If the site is a virtualhost (which most sites seem to be these days), you'll also need to pass the Host: header so that the webserver knows to which virtualhost the request will be passed. For example, if you're making a request to www.example.com for /forums/index.php, a GET request might look like this:

Code:
GET /forums/index.php HTTP/1.0
Host: www.example.com

(FYI, the request is terminated by two newlines.)

Hope that helps!
#3

[eluser]liamstask[/eluser]
Thanks for the quick response Smile

I'm just developing locally at the moment, so I'm connecting to localhost - no virtual hosts, I'm using a stock MAMP setup. I've looked around a bit to try and find a default host name for localhost, but I'm not sure - I've tried passing "localhost" and "127.0.0.1" as the host name, on a whim, but no success. I also added the second newline - thanks for that!

Is there some mod to the Apache conf that I need to do to get this to work?




Theme © iAndrew 2016 - Forum software by © MyBB