Updated workbook: generating response, handling cookies and headers documents.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Nav: [Workbook](../workbook.md) | [Handling Requests: Header Fields](/workbook/handling_request/headers.md) | [Handling Cookies](/workbook/handling_cookies/handling_cookies.md)
|
Nav: [Workbook](../workbook.md) | [Handling Requests: Header Fields](/doc/workbook/handling_request/headers.md) | [Handling Cookies](/doc/workbook/handling_cookies/handling_cookies.md)
|
||||||
|
|
||||||
|
|
||||||
## EWF Generating Response
|
## EWF Generating Response
|
||||||
@@ -164,24 +164,13 @@ Note: use ```res.set_status_code({HTTP_STATUS_CODE}.bad_request)``` rather than
|
|||||||
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
|
||||||
```eiffel
|
```eiffel
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION_EXECUTION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_DEFAULT_SERVICE
|
WSF_EXECUTION
|
||||||
redefine
|
|
||||||
initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make_and_launch
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service.
|
|
||||||
do
|
|
||||||
set_service_option ("port", 9090)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Basic operations
|
feature -- Basic operations
|
||||||
|
|
||||||
@@ -321,24 +310,13 @@ note
|
|||||||
revision : "$Revision$"
|
revision : "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION_EXECUTION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_DEFAULT_SERVICE
|
WSF_EXECUTION
|
||||||
redefine
|
|
||||||
initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make_and_launch
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service.
|
|
||||||
do
|
|
||||||
set_service_option ("port", 9090)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Basic operations
|
feature -- Basic operations
|
||||||
|
|
||||||
@@ -1018,4 +996,4 @@ There are four categories for response header fields:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
| [Handling Requests: Header Fields](/workbook/handling_request/headers.md) | [Handling Cookies](/workbook/handling_cookies/handling_cookies.md)
|
Nav: [Workbook](../workbook.md) | [Handling Requests: Header Fields](/doc/workbook/handling_request/headers.md) | [Handling Cookies](/doc/workbook/handling_cookies/handling_cookies.md)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Nav: [Workbook](../workbook.md) | [Generating Responses](/workbook/generating_response/generating_response.md)
|
Nav: [Workbook](../workbook.md) | [Generating Responses](/doc/workbook/generating_response/generating_response.md)
|
||||||
|
|
||||||
# Handling Cookies
|
# Handling Cookies
|
||||||
|
|
||||||
@@ -146,25 +146,13 @@ note
|
|||||||
revision : "$Revision$"
|
revision : "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
APPLICATION
|
APPLICATION_EXECUTION
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_DEFAULT_SERVICE
|
WSF_EXECUTION
|
||||||
redefine
|
|
||||||
initialize
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make_and_launch
|
make
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
|
||||||
|
|
||||||
initialize
|
|
||||||
-- Initialize current service.
|
|
||||||
do
|
|
||||||
set_service_option ("port", 9090)
|
|
||||||
set_service_option ("verbose",True)
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Basic operations
|
feature -- Basic operations
|
||||||
|
|
||||||
@@ -297,4 +285,4 @@ end
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Nav: [Workbook](../workbook.md) | [Generating Responses](/workbook/generating_response/generating_response.md)
|
Nav: [Workbook](../workbook.md) | [Generating Responses](/doc/workbook/generating_response/generating_response.md)
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ included in the Referer header when the browser requests Web page B.
|
|||||||
<a name="example"></a>
|
<a name="example"></a>
|
||||||
#### Building a Table of All Request Headers
|
#### Building a Table of All Request Headers
|
||||||
|
|
||||||
The following [EWF service](/doc/workbook/headers/header_fields/application.e) code simply uses an ```html_template``` to fill a table (names and values) with all the headers fields it receives.
|
The following [EWF service](/doc/workbook/handling_request/headers/header_fields/application.e) code simply uses an ```html_template``` to fill a table (names and values) with all the headers fields it receives.
|
||||||
|
|
||||||
The service accomplishes this task by calling ```req.meta_variables``` feature to get an ```ITERABLE [WSF_STRING]```, an structure that can be iterated over using ```across...loop...end```, then it checks if the name has the prefix ```HTTP_``` and if it is true, put the header name and value in a row. (the name in the left cell, the value in the right cell).
|
The service accomplishes this task by calling ```req.meta_variables``` feature to get an ```ITERABLE [WSF_STRING]```, an structure that can be iterated over using ```across...loop...end```, then it checks if the name has the prefix ```HTTP_``` and if it is true, put the header name and value in a row. (the name in the left cell, the value in the right cell).
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ To be completed.
|
|||||||
|
|
||||||
#### Detecting Browser Types
|
#### Detecting Browser Types
|
||||||
|
|
||||||
The User-Agent header identifies the specific browser/client that is sending the request. The following code shows a [EWF service](/doc/workbook/headers/browser_name/application.e) that sends browser-specific responses.
|
The User-Agent header identifies the specific browser/client that is sending the request. The following code shows a [EWF service](/doc/workbook/handling_request/headers/browser_name/application.e) that sends browser-specific responses.
|
||||||
|
|
||||||
The examples uses the ideas based on the [Browser detection using the user agent](https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent) article.
|
The examples uses the ideas based on the [Browser detection using the user agent](https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent) article.
|
||||||
Basically the code check if the header user_agent exist and then call the ```browser_name (a_user_agent: READABLE_STRING_8): READABLE_STRING_32```
|
Basically the code check if the header user_agent exist and then call the ```browser_name (a_user_agent: READABLE_STRING_8): READABLE_STRING_32```
|
||||||
@@ -429,7 +429,7 @@ As an exercise, try to write a similar service to retrieve the OS family using t
|
|||||||
* [SERVER_SOFTWARE](https://tools.ietf.org/html/rfc3875#section-4.1.16)
|
* [SERVER_SOFTWARE](https://tools.ietf.org/html/rfc3875#section-4.1.16)
|
||||||
|
|
||||||
**Example**
|
**Example**
|
||||||
An [EWF service](/doc/workbook/headers/cgi_variables/application.e) that shows the CGI variables, creates a table showing the values of all the CGI variables.
|
An [EWF service](/doc/workbook/handling_request/headers/cgi_variables/application.e) that shows the CGI variables, creates a table showing the values of all the CGI variables.
|
||||||
|
|
||||||
|
|
||||||
Nav: [Workbook](../workbook.md) | [Handling Requests: Form/Query parameters] (/doc/workbook/handling_request/form.md) | [Generating Responses](/doc/workbook/generating_response/generating_response.md)
|
Nav: [Workbook](../workbook.md) | [Handling Requests: Form/Query parameters] (/doc/workbook/handling_request/form.md) | [Generating Responses](/doc/workbook/generating_response/generating_response.md)
|
||||||
|
|||||||
Reference in New Issue
Block a user