To use this:
Install httpie via pip inside a virtualenv, executing the following command:
pip install httpie
Execute HTTP Server script on your machine, executing the following command:
python3 my-httpserver.py
Test a HEAD request using
http
script fromhttpie
package, executing the following command:http -v HEAD http://127.0.0.1:8085/
The response it should be like the following:
HEAD / HTTP/1.1
Accept: /
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: 127.0.0.1:8085
User-Agent: httpie/0.9.9
HTTP/1.0 200 OK
Content-type: text/html
Date: Thu, 04 Oct 2018 02:26:54 GMT
Server: BaseHTTP/0.6 Python/3.5.3
Test a GET request using
http
script fromhttpie
package, executing the following command:python3 my-httpclient.py 127.0.0.1:8085
then it show like this:HTTP Client is starting...
Enter a input command (example GET test.html, type "exit" to end it):
Them you can enter a input command like
GET test.html
and the response it should be like the following:200 OK
b'<html>n <head>n <title>HTTP GET verb</title>n </head>n <body>n <h1>This is a GET verb!</h1>n </body>n</html>n'
Test a POST request using
http
script fromhttpie
package, executing the following command:http --form POST http://127.0.0.1:8085/ message="Hello World"
The response it should be like the following:
HTTP/1.0 200 OK
Content-type: text/html
Date: Thu, 04 Oct 2018 12:24:09 GMT
Last-Modified: Thu, 04 Oct 2018 12:24:09 GMT
Server: BaseHTTP/0.6 Python/3.5.3
HTTP/1.0 200 OK
Server: BaseHTTP/0.6 Python/3.5.3
Date: Thu, 04 Oct 2018 12:24:09 GMT
Content-type: text/html
Last-Modified: Thu, 04 Oct 2018 12:24:09 GMT
<html>
<body>
<h1>POST verb demo</h1>
<p>The message is 'Hello World'.</p>
<br />
<p>This is a POST verb!</p>
</body>
</html>