... | ... | @@ -103,7 +103,7 @@ This is the **format** of for request messages: |
|
|
The **request line** is the most important part. Here is where the client tells the server the service it needs. It consist of **three parts** separated by one space:
|
|
|
|
|
|
* **Method**: Command name. There are three: GET, POST, and HEAD
|
|
|
* **GET**: Requests an **object** from the server. The object id is provided using the argument _path_
|
|
|
* **GET**: Requests an **object** from the server. The object id is provided using the argument *path*
|
|
|
* **POST**: The client wants to send data to the server. These data are placed in the message body
|
|
|
* **HEAD**: Similar to GET, but only the object's header us requested. It is used by the client to know if the object has been modified without having to transfer the whole object
|
|
|
* **Path**: It is the name of the object that the client wants to get from the server, or the object which will receive the data the client is sending
|
... | ... | @@ -549,8 +549,8 @@ We will see that now the \*\*\*\*Content-Type header of the response message is |
|
|
</html>
|
|
|
```
|
|
|
|
|
|
* **HTML documents** should always start with the special tag: <!DOCTYPE html>
|
|
|
* The rest of the html code is within the boundaries of the **<html>** and **</html>** tags. The attributes specified along with the **<html>** tag specify, in this case, that we are working in English, reading from left to right
|
|
|
* **HTML documents** should always start with the special tag: **\<!DOCTYPE html\>**
|
|
|
* The rest of the html code is within the boundaries of the **\<html>** and **\</html>** tags. The attributes specified along with the **\<html>** tag specify, in this case, that we are working in English, reading from left to right
|
|
|
* Every html document consist of two parts: the **head** and the **body**
|
|
|
* The **head** contains information for the browser, about the document it is receiving
|
|
|
* The actual content is located in the **body**
|
... | ... | @@ -563,28 +563,28 @@ We will see that now the \*\*\*\*Content-Type header of the response message is |
|
|
|
|
|
## Exercises
|
|
|
|
|
|
All the exercises and experiments performed during this session should be stored in the **Session-12 folder**
|
|
|
All the exercises and experiments donde during this session should be stored in the **S12** folder.
|
|
|
|
|
|
### Exercise 1
|
|
|
|
|
|
* **Filename**: Session-12/exercise-1.txt
|
|
|
* **Description**: A Text file in which you should write down you answers to the exercise 1
|
|
|
|
|
|
Run the **web-server-2**. Open the browser and connect to the URL: [**http://127.0.0.1:8080/hello**](http://127.0.0.1:8080/hello). Answer the following questions:
|
|
|
* **Filename**: S12/e1.txt
|
|
|
* **Description**: A text file to answer the following questions
|
|
|
*
|
|
|
Run the **webserver-2**. Open the browser and connect to the URL: [**http://127.0.0.1:8080/hello**](http://127.0.0.1:8080/hello)
|
|
|
|
|
|
* Which is the request line?
|
|
|
* Which is the resource name that the client is asking for? (Path)
|
|
|
* Which is the resource that the client is asking for? (the path)
|
|
|
|
|
|
Repeat the exercise for this URL: **http://127.0.0.1:8080/file.html**
|
|
|
|
|
|
Repeat the exercise for this URL: [**http://127.0.0.1:8080/hi/there?name=virus&type=corona**](http://127.0.0.1:8080/hi/there?name=virus&type=corona)
|
|
|
|
|
|
What should be the URL that we have to write in the Browser for accessing the /dna/u5 resource?
|
|
|
* What should be the URL that we have to write in the browser for accessing the /dna/u5 resource?
|
|
|
|
|
|
### Exercise 2
|
|
|
|
|
|
* **Filename**: Session-12/we-server-Ex2.py
|
|
|
* **Description**: It is the web-server-2.py server, modify so that the **Content-Type** header has the value: **text/plain**
|
|
|
* **Filename**: S12/webserver-e2.py
|
|
|
* **Description**: Modify the server we have developed during this session so that the **Content-Type** header has the value: **text/plain**
|
|
|
|
|
|
**Run** the server and use the **curl tool** to confirm that the response message has the new header:
|
|
|
|
... | ... | @@ -596,8 +596,8 @@ Try to connect from the Browser. What happens? Could you see the web page? (is t |
|
|
|
|
|
### Exercise 3
|
|
|
|
|
|
* **Filename**: Session-12/we-server-Ex3.py
|
|
|
* **Description**: It is the web-server-2.py server, modified so that the **Content-Length** header has the value: **5**
|
|
|
* **Filename**: S12/webserver-e3.py
|
|
|
* **Description**: Modify the server we have developed during this session so that the **Content-Length** header has the value **5**
|
|
|
|
|
|
When you connect from the browser without any change in the Content-Length you will see the Green server... but What happens when you modify the Content-Length?
|
|
|
|
... | ... | @@ -605,9 +605,9 @@ Test it with the curl command. Could you see the HTML message? |
|
|
|
|
|
### Exercise 4
|
|
|
|
|
|
* **Filename**: Session-12/we-server-Ex4.py
|
|
|
* **Description**: It is the web-server-2.py server, modified so that it reads the **index.html** file and sends it as a response to the client
|
|
|
* **Filename**: Session12/index.html
|
|
|
* **Filename**: S12/webserver-e4.py
|
|
|
* **Description**: Modify the server we have developed during this session so so that it reads the **index.html** file and sends it as a response to the client
|
|
|
* **Filename**: S12/index.html
|
|
|
* **Description**: The HTML page of the Green server, in a file
|
|
|
|
|
|
```html
|
... | ... | @@ -624,26 +624,25 @@ Test it with the curl command. Could you see the HTML message? |
|
|
</html>
|
|
|
```
|
|
|
|
|
|
When you connect from the browser, you will se the Green server web page
|
|
|
When you connect from the browser, you will se the Green server web page.
|
|
|
|
|
|
Once it is working, modify the file **index.html** so that the message that appears is: "I am the Green Server! :-) (MODIFIED BY ME!!!!)"
|
|
|
|
|
|
## END of the session
|
|
|
|
|
|
The session is finished. Make sure, during this week, that everything in this list is checked!
|
|
|
The session is finished. Make sure during this week that everything in this list is checked!
|
|
|
|
|
|
* [ ] You have all the items of the session 11 checked!
|
|
|
* [ ] Your working repo contains the **Session-12 Folder** with the following files:
|
|
|
* [ ] echo-server.py
|
|
|
* [ ] web-server-1.py
|
|
|
* [ ] web-server-2.py
|
|
|
* [ ] exercise-1.txt
|
|
|
* [ ] web-server-Ex2.py
|
|
|
* [ ] web-server-Ex3.py
|
|
|
* [ ] web-server-Ex4.py
|
|
|
* [ ] webserver-1.py
|
|
|
* [ ] webserver-2.py
|
|
|
* [ ] e1.txt
|
|
|
* [ ] webserver-e2.py
|
|
|
* [ ] webserver-e3.py
|
|
|
* [ ] webserver-e4.py
|
|
|
* [ ] index.html
|
|
|
* [ ] All the previous files have been pushed to your remote Github repo
|
|
|
|
|
|
# Credits
|
|
|
|
|
|
* Rodrigo Pérez Rodríguez
|
... | ... | |