diff --git a/specs/http-client-2/index.html b/specs/http-client-2/index.html index f2dc25c..53da61e 100644 --- a/specs/http-client-2/index.html +++ b/specs/http-client-2/index.html @@ -131,6 +131,12 @@ font-weight: bolder; font-style: italic; } + .constants-table th:nth-child(3) { + text-align: right; + } + .constants-table td:nth-child(3) { + text-align: right; + }
@@ -528,29 +534,170 @@xs:booleanfalse()Ignore the headers and body in the HTTP response.
-This may be used to save resources on parsing the response when the user is - only interested in the response code.
-xs:booleantrue()map(xs:string, *)
+map {
+ "mode": $http:parse-mode-full,
+ "entity": $http:parse-entity-auto
+}Indicates if the response bodies will be parsed (see - ).
-When set to true(), if status-only is also set to
- true(), the error http:invalid-option MUST be raised.
Controls the parsing of the HTTP response. Entries for the map are detailed in + .
+ The following parse-response options can be specified to control HTTP response parsing: +
+ +| Entry Key | +XDM Type | +Default | +Description | +
|---|---|---|---|
| mode | +xs:string |
+ $http:parse-mode-full |
+
+ Determines the extent to which the HTTP response is parsed before being returned from the function + call as the response map. Parsing of the HTTP response requires processing, so some + implementations may be able to optimize for some of the simpler parsing modes. Valid values are: +
|
+
| entity | +xs:string+ |
+ $http:parse-entity-auto |
+
+ Overrides the implicit automatic parsing defined in + . +If this option is specified and the mode is not set to Where a multipart response is expected, a sequence of values may be specified. + If there are less values than multipart parts, then the last value will apply to the remaining + multipart parts. +Valid values are: +
|
+
http:get('http://expath.org/xyz', map {
'status-only': true(),
@@ -722,7 +869,8 @@ The Response
When the HTTP request is made to the server indicated by the request $uri, if the
server processes the request and responds to the client within the timeout then the
- HTTP response from the server is returned as the result of the function as a map.
+ HTTP response from the server is returned as the result of the function as a map, this is known as the
+ Response Map.
If the server fails to respond to an HTTP request within the timeout then the error
http:timeout MUST be raised. If the HTTP request cannot be made to the server then
@@ -732,14 +880,13 @@
The Response
The Response Map
- The HTTP response map contains the following entries. Optional entries are entirely absent
+ The HTTP Response Map contains the following entries. Optional entries are entirely absent
from the map if the HTTP response does not contain the corresponding data, for example no body is returned, there will be no body entry.
Response Entries
-
@@ -748,7 +895,6 @@ The Response Map
Response Key
XDM Type
- Optional
Description
@@ -756,7 +902,6 @@ The Response Map
http-version
xs:string
- No
The HTTP Version of the response. This may differ from the
http-version requested!
@@ -765,7 +910,6 @@ The Response Map
status
xs:string
- No
The HTTP status code.
@@ -773,7 +917,6 @@ The Response Map
message
xs:string
- No
HTTP reason phrase.
@@ -781,13 +924,11 @@ The Response Map
headers
map(xs:string, xs:string)
- Yes
HTTP response header fields.
body
item()+
- Yes
HTTP response body.
@@ -833,7 +974,7 @@ The Response Entity Body
For those cases where the server is not responding faithfully to the request, or the developer
needs a greater level of control over the response, the implicit parsing of the response entity
- body can be disabled via the parse-response-entity-body request option,
+ body can be disabled via the parse-response request option,
see .
@@ -883,6 +1024,7 @@ Implicit Parsing
document-node()
Parsed as XML.
+ NOTE: this will logically also include XHTML with the mimetype application/xhtml+xml.
@@ -946,13 +1088,11 @@ Implicit Parsing
Explicit Parsing
- Implicit parsing of the response body can be disabled via the parse-response-entity-body
- request option. All bodies of single and multipart responses will be returned as binary items
- of type xs:base64Binary, and the values can be processed (stored, parsed,
- forwarded) in a second step.
+ Implicit parsing of the response body can be disabled via the parse-response
+ request option, which allows the parsing to be explicitly specified.
-
+
(:~
: Parses a response and returns the parsed body values.
: @param $response response (top-level, multipart)
@@ -980,7 +1120,12 @@ Explicit Parsing
local:parse(
http:get('http://expath.org/xyz',
- map { 'parse-response-entity-body': false() })
+ map { 'parse-response':
+ map {
+ 'entity': $http:parse-entity-raw()
+ }
+ }
+ )
)
@@ -989,6 +1134,97 @@ Explicit Parsing
+
+ Constants
+ This section defines the constants which are defined by the HTTP module. Each constant is
+ defined as a variable. The purpose of these constants is to reduce developer error where otherwise
+ common strings or values would have to be reproduced.
+
+
+ Constants
+
+
+
+
+
+
+
+
+ Variable
+ XDM Type
+ Value
+
+
+
+
+ $http:parse-entity-auto
+ xs:string
+ auto
+
+
+ $http:parse-entity-xml
+ xs:string
+ xml
+
+
+ $http:parse-entity-html-to-xml
+ xs:string
+ html2xml
+
+
+ $http:parse-entity-json
+ xs:string
+ json
+
+
+ $http:parse-entity-text
+ xs:string
+ text
+
+
+ $http:parse-entity-raw
+ xs:string
+ raw
+
+
+ $http:parse-entity-none
+ xs:string
+ none
+
+
+ $http:parse-mode-raw
+ xs:string
+ raw
+
+
+ $http:parse-mode-status
+ xs:string
+ status
+
+
+ $http:parse-mode-headers
+ xs:string
+ headers
+
+
+ $http:parse-mode-multipart-raw
+ xs:string
+ multipart-raw
+
+
+ $http:parse-mode-multipart-headers
+ xs:string
+ multipart-headers
+
+
+ $http:parse-mode-full
+ xs:string
+ full
+
+
+
+
+
Errors
This section defines and describes the error codes that may be raised by the module.