[Migrated content. Thread originally posted on 01 March 2004]
I'm looking for an example of sending and receiving an html request in cobol.
The purpose is to send a request to a sms server like '
sms.server.com 310000000&message=test'.
then to receive de answer of the server which is a short html page with a status (which i want to check in my the cobol program).
If possible an example with c$socket. Thx.
A useful way to test your knowledge of the HTTP protocol is to "manually" submit an HTTP request to a web server using your favorite Telnet client. (You can use the Windows "telnet" command from a command prompt, any standard Unix "telnet" command, or a terminal emulator like PuTTY). I don't like to use the Windows telnet client because it has local echo disabled so you can't see what you're typing. Your mileage may vary. Here is a simple, interactive HTTP "session" from a Unix shell prompt (
Bold indicates
your input):
$
telnet http://www.acucorp.com 80 Trying 65.248.23.134...
Connected to
http://www.acucorp.com.Escape character is '^]'.
GET {URL} HTTP/1.1Host: http://www.acucorp.comConnection: close(now hit Enter twice in a row) {URL} can be an absolute URL, beginning with http://, or it can be a relative URL like /support/index.php. If your request needs to include a query string (the part after the first ?) be sure to include it here.
After you've hit Enter twice (which signals the server that you've completed your request), you should see the server's reply, beginning with several lines comprising the HTTP Response -- something like:
HTTP/1.1 200 OK
Date: Fri, 12 Mar 2004 01:30:46 GMT
Server: Apache/1.3.27 (Unix) mod_perl/1.27 PHP/4.2.3 mod_fastcgi/2.2.12 FrontPage/5.0.2.2510 mod_jk/1.2.0 mod_ssl/2.8.11 OpenSSL/0.9.6g
Last-Modified: Thu, 19 Feb 2004 07:44:04 GMT
ETag: "51894f-43c-40346944"
Accept-Ranges: bytes
Content-Length: 1084
Connection: close
Content-Type: text/html; charset=iso-8859-1
This will be followed by an blank line (actually a pair of CR/LF's), then the HTML content. Then you will usually be notified that the connection has indeed been closed:
Connection closed by foreign host.
The key here is that a valid HTTP request must consist of at least the following:
The request method (such as GET, POST or HEAD), followed by a space, then the URL you're requesting, then the protocol version.
Also required by HTTP version 1.1 is the Host: field, since an individual machine might be hosting several "virtual hosts", so you need to tell it which one. The Connection: field is optional, it just tells the server that it's okay to close the connection when it's done sending the response. And finally, your request must be terminated by a pair of CR/LF's to signal the end of your request.
[Migrated content. Thread originally posted on 01 March 2004]
I'm looking for an example of sending and receiving an html request in cobol.
The purpose is to send a request to a sms server like '
sms.server.com 310000000&message=test'.
then to receive de answer of the server which is a short html page with a status (which i want to check in my the cobol program).
If possible an example with c$socket. Thx.
A useful way to test your knowledge of the HTTP protocol is to "manually" submit an HTTP request to a web server using your favorite Telnet client. (You can use the Windows "telnet" command from a command prompt, any standard Unix "telnet" command, or a terminal emulator like PuTTY). I don't like to use the Windows telnet client because it has local echo disabled so you can't see what you're typing. Your mileage may vary. Here is a simple, interactive HTTP "session" from a Unix shell prompt (
Bold indicates
your input):
$
telnet http://www.acucorp.com 80 Trying 65.248.23.134...
Connected to
http://www.acucorp.com.Escape character is '^]'.
GET {URL} HTTP/1.1Host: http://www.acucorp.comConnection: close(now hit Enter twice in a row) {URL} can be an absolute URL, beginning with http://, or it can be a relative URL like /support/index.php. If your request needs to include a query string (the part after the first ?) be sure to include it here.
After you've hit Enter twice (which signals the server that you've completed your request), you should see the server's reply, beginning with several lines comprising the HTTP Response -- something like:
HTTP/1.1 200 OK
Date: Fri, 12 Mar 2004 01:30:46 GMT
Server: Apache/1.3.27 (Unix) mod_perl/1.27 PHP/4.2.3 mod_fastcgi/2.2.12 FrontPage/5.0.2.2510 mod_jk/1.2.0 mod_ssl/2.8.11 OpenSSL/0.9.6g
Last-Modified: Thu, 19 Feb 2004 07:44:04 GMT
ETag: "51894f-43c-40346944"
Accept-Ranges: bytes
Content-Length: 1084
Connection: close
Content-Type: text/html; charset=iso-8859-1
This will be followed by an blank line (actually a pair of CR/LF's), then the HTML content. Then you will usually be notified that the connection has indeed been closed:
Connection closed by foreign host.
The key here is that a valid HTTP request must consist of at least the following:
The request method (such as GET, POST or HEAD), followed by a space, then the URL you're requesting, then the protocol version.
Also required by HTTP version 1.1 is the Host: field, since an individual machine might be hosting several "virtual hosts", so you need to tell it which one. The Connection: field is optional, it just tells the server that it's okay to close the connection when it's done sending the response. And finally, your request must be terminated by a pair of CR/LF's to signal the end of your request.
[Migrated content. Thread originally posted on 01 March 2004]
I'm looking for an example of sending and receiving an html request in cobol.
The purpose is to send a request to a sms server like '
sms.server.com 310000000&message=test'.
then to receive de answer of the server which is a short html page with a status (which i want to check in my the cobol program).
If possible an example with c$socket. Thx.
A useful way to test your knowledge of the HTTP protocol is to "manually" submit an HTTP request to a web server using your favorite Telnet client. (You can use the Windows "telnet" command from a command prompt, any standard Unix "telnet" command, or a terminal emulator like PuTTY). I don't like to use the Windows telnet client because it has local echo disabled so you can't see what you're typing. Your mileage may vary. Here is a simple, interactive HTTP "session" from a Unix shell prompt (
Bold indicates
your input):
$
telnet http://www.acucorp.com 80 Trying 65.248.23.134...
Connected to
http://www.acucorp.com.Escape character is '^]'.
GET {URL} HTTP/1.1Host: http://www.acucorp.comConnection: close(now hit Enter twice in a row) {URL} can be an absolute URL, beginning with http://, or it can be a relative URL like /support/index.php. If your request needs to include a query string (the part after the first ?) be sure to include it here.
After you've hit Enter twice (which signals the server that you've completed your request), you should see the server's reply, beginning with several lines comprising the HTTP Response -- something like:
HTTP/1.1 200 OK
Date: Fri, 12 Mar 2004 01:30:46 GMT
Server: Apache/1.3.27 (Unix) mod_perl/1.27 PHP/4.2.3 mod_fastcgi/2.2.12 FrontPage/5.0.2.2510 mod_jk/1.2.0 mod_ssl/2.8.11 OpenSSL/0.9.6g
Last-Modified: Thu, 19 Feb 2004 07:44:04 GMT
ETag: "51894f-43c-40346944"
Accept-Ranges: bytes
Content-Length: 1084
Connection: close
Content-Type: text/html; charset=iso-8859-1
This will be followed by an blank line (actually a pair of CR/LF's), then the HTML content. Then you will usually be notified that the connection has indeed been closed:
Connection closed by foreign host.
The key here is that a valid HTTP request must consist of at least the following:
The request method (such as GET, POST or HEAD), followed by a space, then the URL you're requesting, then the protocol version.
Also required by HTTP version 1.1 is the Host: field, since an individual machine might be hosting several "virtual hosts", so you need to tell it which one. The Connection: field is optional, it just tells the server that it's okay to close the connection when it's done sending the response. And finally, your request must be terminated by a pair of CR/LF's to signal the end of your request.