Removed extra indentations.

This commit is contained in:
Jocelyn Fiat
2017-02-15 17:54:17 +01:00
parent 94f3c3b849
commit e0d3ceb4e8

View File

@@ -9,7 +9,7 @@ Nav: [Workbook](../workbook.md) :: [Handling Requests: Header Fields](../handlin
- [How to set status code](#status_set) - [How to set status code](#status_set)
- [How to redirect to a particular location.](#redirect) - [How to redirect to a particular location.](#redirect)
- [HTTP Status codes](#status) - [HTTP Status codes](#status)
- [Example Staus Codes](#example_1) - [Example Status Codes](#example_1)
- [Generic Search Engine](#example_2) - [Generic Search Engine](#example_2)
- [Response Header Fields](#header_fields) - [Response Header Fields](#header_fields)
@@ -21,31 +21,31 @@ Nav: [Workbook](../workbook.md) :: [Handling Requests: Header Fields](../handlin
As we saw in the previous documents, a request from a user-agent (browser or other client) consists of an HTTP command (usually GET or POST), zero or more request headers (one or more in HTTP 1.1, since Host is required), a blank line, and only in the case of POST/PUT requests, payload data. A typical request looks like the following. As we saw in the previous documents, a request from a user-agent (browser or other client) consists of an HTTP command (usually GET or POST), zero or more request headers (one or more in HTTP 1.1, since Host is required), a blank line, and only in the case of POST/PUT requests, payload data. A typical request looks like the following.
``` ```
GET /url[query_string] HTTP/1.1 GET /url[query_string] HTTP/1.1
Host: ... Host: ...
Header2: ... Header2: ...
... ...
HeaderN: HeaderN:
(Blank Line) (Blank Line)
``` ```
When a Web server responds to a request, the response typically consists of a status line, some response headers, a blank line, and the document. A typical response When a Web server responds to a request, the response typically consists of a status line, some response headers, a blank line, and the document. A typical response
looks like this: looks like this:
``` ```
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: text/html Content-Type: text/html
Header2: ... Header2: ...
... ...
HeaderN: ... HeaderN: ...
(Blank Line) (Blank Line)
<!DOCTYPE ...> <!DOCTYPE ...>
<HTML> <HTML>
<HEAD>...</HEAD> <HEAD>...</HEAD>
<BODY> <BODY>
... ...
</BODY> </BODY>
</HTML> </HTML>
``` ```
The status line consists of the HTTP version (HTTP/1.1 in the preceding example), a status code (an integer 200 in the example), and a very short message corresponding to the status code (OK in the example). In most cases, the headers are optional except for Content-Type, which specifies the MIME type of the document that follows. Although most responses contain a document, some dont. For example, responses to HEAD requests should never include a document, and various status codes essentially indicate failure or redirection (and thus either dont include a document or include only a short error-message document). The status line consists of the HTTP version (HTTP/1.1 in the preceding example), a status code (an integer 200 in the example), and a very short message corresponding to the status code (OK in the example). In most cases, the headers are optional except for Content-Type, which specifies the MIME type of the document that follows. Although most responses contain a document, some dont. For example, responses to HEAD requests should never include a document, and various status codes essentially indicate failure or redirection (and thus either dont include a document or include only a short error-message document).
@@ -60,7 +60,7 @@ If you need to set an arbitrary status code, you can use the `WSF_RESPONSE.put_h
In this case you provide the status code with a collection of headers. In this case you provide the status code with a collection of headers.
```eiffel ```eiffel
put_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]) put_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Put headers with status `a_status', and headers from `a_headers' -- Put headers with status `a_status', and headers from `a_headers'
require require
a_status_code_valid: a_status_code > 0 a_status_code_valid: a_status_code > 0
@@ -167,7 +167,7 @@ Note: use `res.set_status_code({HTTP_STATUS_CODE}.bad_request)` rather than `res
<a name="example_1"></a> <a name="example_1"></a>
### Example Staus Codes ### Example Status Codes
Basic Service that builds a simple web page to show the most common status codes Basic Service that builds a simple web page to show the most common status codes
@@ -567,7 +567,7 @@ Connection: close
</html> </html>
``` ```
#### Resource searchs not found #### Resource search not found
``` ```
#>curl -i -H -v -X POST -d "query=Eiffel&engine=Google" http://localhost:9090/searchs #>curl -i -H -v -X POST -d "query=Eiffel&engine=Google" http://localhost:9090/searchs
@@ -611,13 +611,13 @@ features `add_XYZ` add headers that can lead to duplicated entries.
```eiffel ```eiffel
add_header_line (h: READABLE_STRING_8) add_header_line (h: READABLE_STRING_8)
-- Add header `h' -- Add header `h'
-- This can lead to duplicated header entries -- This can lead to duplicated header entries
require require
header_not_committed: not header_committed header_not_committed: not header_committed
add_header_text (a_text: READABLE_STRING_8) add_header_text (a_text: READABLE_STRING_8)
-- Add the multiline header `a_text' -- Add the multiline header `a_text'
-- Does not replace existing header with same name -- Does not replace existing header with same name
-- This could leads to multiple header with the same name -- This could leads to multiple header with the same name
@@ -629,13 +629,13 @@ features `add_XYZ` add headers that can lead to duplicated entries.
status_set: status_is_set status_set: status_is_set
message_writable: message_writable message_writable: message_writable
put_header_line (h: READABLE_STRING_8) put_header_line (h: READABLE_STRING_8)
-- Put header `h' -- Put header `h'
-- Replace any existing value -- Replace any existing value
require require
header_not_committed: not header_committed header_not_committed: not header_committed
put_header_text (a_text: READABLE_STRING_8) put_header_text (a_text: READABLE_STRING_8)
-- Put the multiline header `a_text' -- Put the multiline header `a_text'
-- Overwite potential existing header -- Overwite potential existing header
require require
@@ -644,10 +644,12 @@ features `add_XYZ` add headers that can lead to duplicated entries.
a_text_does_not_end_with_double_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N") a_text_does_not_end_with_double_crlf: a_text.count > 4 implies not a_text.substring (a_text.count - 4, a_text.count).same_string ("%R%N%R%N")
ensure ensure
message_writable: message_writable message_writable: message_writable
```
helpers helpers
add_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]) ```eiffel
add_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Put headers with status `a_status', and headers from `a_headers' -- Put headers with status `a_status', and headers from `a_headers'
require require
a_status_code_valid: a_status_code > 0 a_status_code_valid: a_status_code > 0
@@ -658,12 +660,12 @@ helpers
status_set: status_is_set status_set: status_is_set
message_writable: message_writable message_writable: message_writable
add_header_lines (a_lines: ITERABLE [READABLE_STRING_8]) add_header_lines (a_lines: ITERABLE [READABLE_STRING_8])
-- Add headers from `a_lines' -- Add headers from `a_lines'
require require
header_not_committed: not header_committed header_not_committed: not header_committed
put_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]) put_header (a_status_code: INTEGER_32; a_headers: detachable ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
-- Put headers with status `a_status', and headers from `a_headers' -- Put headers with status `a_status', and headers from `a_headers'
require require
a_status_code_valid: a_status_code > 0 a_status_code_valid: a_status_code > 0
@@ -674,7 +676,7 @@ helpers
status_set: status_is_set status_set: status_is_set
message_writable: message_writable message_writable: message_writable
put_header_lines (a_lines: ITERABLE [READABLE_STRING_8]) put_header_lines (a_lines: ITERABLE [READABLE_STRING_8])
-- Put headers from `a_lines' -- Put headers from `a_lines'
require require
header_not_committed: not header_committed header_not_committed: not header_committed
@@ -687,7 +689,7 @@ take a look at constants classes such as `HTTP_MIME_TYPES`,`HTTP_HEADER_NAMES`,`
```eiffel ```eiffel
custom_answer (req: WSF_REQUEST; res: WSF_RESPONSE; output: STRING) custom_answer (req: WSF_REQUEST; res: WSF_RESPONSE; output: STRING)
local local
h: HTTP_HEADER h: HTTP_HEADER
l_msg: STRING l_msg: STRING