4 <li>https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
</li>
5 <li>https://www.rfc-editor.org/rfc/rfc2616
</li>
6 <li>https://curl.se/docs/manpage.html
</li>
9 <p>In the
1991 HTTP was created. Web browsers used HTTP to fetch static HTML, text and images from web servers. These static files were sitting in a directory on a server. The only way to change the website was to update these files.
</p>
10 <p>You could type a URL like
<code>http://acme.com/products.html
</code> into a graphical web browser, the browser would then speak HTTP to the
<code>acme.com
</code> server to fetch the
<code>/products.html
</code> file. The user may then click a
<code><a
href=
"http://contoso.net/about.html"></code> to cause the browser to visit a different site, speaking HTTP to the
<code>contoso.net
</code> server to fetch the
<code>/about.html
</code> file.
</p>
11 <h2>Learning objective
</h2>
12 <p>The goal is to learn about HTTP, specifically what it does and what it looks like.
<br />
13 - What is an HTTP method?
<br />
14 - What is an HTTP status code?
<br />
15 - Identify the components of a URL, server, path.
<br />
16 - How does an HTTP server use the server and path from the URL?
</p>
18 <h3>Run a simple web server using Python
</h3>
20 <li>Make new directory with some text or html files, at least two. Eg demo.html and hello.txt.
</li>
21 <li>Open terminal in that directory. Right click, open in terminal.
</li>
22 <li>Start the web server:
<code>python -mhttp.server
</code></li>
23 <li>Keep this terminal window open for later.
</li>
25 <h3>Access the web server with a browser like Firefox
</h3>
27 <li>Open web browser and visit: http://localhost:
8000</li>
28 <li>See what is happening in the web server terminal window.
</li>
29 <li>You can click on the files to view them.
</li>
30 <li>The browser is acting as an HTTP client to view the files being served by the Python HTTP server.
</li>
32 <h3>Access the web server with a command line client, curl
</h3>
34 <li>Open a new terminal window in addition to the Python web server one.
</li>
35 <li>Run
<code>curl http://localhost:
8000</code> to see the directory index generated by the web server.
</li>
36 <li>Run
<code>curl http://localhost:
8000/demo.html
</code> to see a file you created in the web server directory.
</li>
37 <li>Try variations of this like:
<code>/hello.txt
</code>, or
<code>/missing.txt
</code></li>
38 <li>You can also try this on other web servers, like
<code>https://www.google.com
</code></li>
39 <li>Try in verbose mode to see the raw HTTP:
<code>curl -v http://localhost:
8000</code></li>
41 <h3>Access the web server by typing raw HTTP
</h3>
43 <li>Run command
<code>nc localhost
8000</code></li>
44 <li>Enter
<code>GET / HTTP/
1.0</code>, then press return twice
</li>
45 <li>Try with
<code>GET /hello.txt
</code> or other variations to see how the server responds.
</li>
47 <p>HTTP is just text! When you click a link, all that Firefox does is send this text to the server and display the result on the screen.
</p>