View Full Version : http from the command line
Does anybody know the syntax for performing an http get or http post request from the command line? Thanks.
Which command line? Using what program? With what data?
The general format for a minimal GET request is:
GET /path/to/resource HTTP/1.1
Host: www.example.com
Connection: close
<blank line>
mburt
06-02-2007, 05:53 PM
I think the OP wants to access information similarly to the way AJAX does from a server... just a guess, though.
ItsMeOnly
06-03-2007, 10:53 AM
telnet yourserver.com 80
GET /
Just a thought
That request lacks the HTTP version and the Host header, which is vital for HTTP/1.1. A correct GET request should look as mine does above (although the Connection header isn't vital).
Which command line? Using what program? With what data?
My apologies if I was too vague. I'm using php. I know that php has a function class that does this, but it's not bundled on my server, so I thought I'd use shell scripting on the command line with the exec() function. I need to send name-value pairs to another server using the POST method and with no form. I also need to get name-value pairs back from that server, but I'm assuming this is as simple as "extract($_POST);".
You'll need to write a basic HTTP client using fsockopen (http://www.php.net/fsockopen)().
mburt
06-07-2007, 12:53 PM
Wouldn't exec() work fine?
Well yes, but fsockopen() would be simpler, and more likely to work.
Well yes, but fsockopen() would be simpler, and more likely to work.
I don't really know what this means . . .
edit: I'm sorry, I'm being vague again. What i meant to say is that I dont understand the documentation at php.net.
It's very simple. Use fsockopen() to open a connection to a server, then you can read from and write to it like a normal file.
It's very simple. Use fsockopen() to open a connection to a server, then you can read from and write to it like a normal file.
Okay, I think i get it now. Thanks. I'll mess around with this tonight when i get home.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.