From 562dd57e4607d9c1ec3d31b69c8e018a6786abb4 Mon Sep 17 00:00:00 2001
From: Adam Retter Parsed as XML. NOTE: this will logically also include XHTML with the mimetype 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. Indicates if the response bodies will be parsed (see
- ). When set to 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:
+ 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: No parsing of the HTTP response is performed. The entire response is returned as
+ Only the status line from the HTTP response is
+ parsed. Only the From the HTTP response, only the status line,
+ general headers,
+ response headers, and
+ entity headers will all be parsed. All fields apart
+ from the When the HTTP response is a multipart response, first the
+ status line,
+ general headers,
+ response headers, and
+ entity headers of the HTTP response will be parsed,
+ setting the Secondly the response's entity body will be minimally parsed; Only extracting each entity from
+ the body in raw form. That is to say, that each multipart entity within the entity body will not
+ have its headers parsed. The entity will be delivered in its raw form in the If the response is not a multipart response, and this mode is set, then the error
+ http:parse MUST be raised. When the HTTP response is a multipart response, first the
+ status line,
+ general headers,
+ response headers, and
+ entity headers of the HTTP response will be parsed,
+ setting the Secondly the response's entity body will only be minimally parsed; Only extracting the headers
+ of each entity within the body. That is to say, that each multipart entity within the entity
+ body will have its body ignored. Only the If the response is not a multipart response, and this mode is set, then the error
+ http:parse MUST be raised. The entire HTTP response is parsed automatically according to the rules in
+ , and all the entries in the response
+ map are set (apart from the 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: The entity will be parsed as XML. The result is a The entity will be parsed using a HTML parser which can produce XML output.
+ The result is a Implementations are not required to support this option. If an implementation does not support
+ this it MUST raise the error http:invalid-option. The entity will be parsed using a JSON parser. The result is either a The entity will be parsed as text. The result is an The entity will be extracted as is. The result is an The entity will be not be parsed. The result is an
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.Implicit Parsing
document-node()
application/xhtml+xml.
From eb4f88514f9189554e41fb2f838016a09f08f633 Mon Sep 17 00:00:00 2001
From: Adam Retter
Request Options
-
- status-only
-
- xs:boolean
- false()
-
-
-
+ parse-response-entity-body
-
- xs:boolean
+ true()parse-response
+
+ map(xs:string, *)
+map {
+ "mode": $http:parse-mode-full,
+ "entity": $http:parse-entity-auto
+}
-
true(), if status-only is also set to
- true(), the error http:invalid-option MUST be raised.Parse Response Options
+
+
+
+
+
+
+ Entry Key
+ XDM Type
+ Default
+ Description
+
+
+ mode
+
+ xs:string
+ $http:parse-mode-full
+
+
+
+ xs:base64Binary in the body of the response map, all other
+ entries of the response map are omitted.http-version, status, and message
+ entries will be present in the response map.body will be present in the response map.http-version, status, and message in the
+ response map.body
+ entry of the part body and the part body's headers entry will be omitted. Each
+ part body will be set in the body entry of the response map.http-version, status, and message in the
+ response map.headers of the part body entry will be
+ set, and each part body will be set in the body entry of the response map.body entry when the HTTP response has no body).
+
+
+ entity
+
+ xs:string+
+ $http:parse-entity-auto
+
+ $http:parse-mode-full,
+ then the error http:invalid-option MUST be raised.
+
+ document-node().document-node().map(*),
+ array(*), xs:string, xs:double, xs:boolean,
+ or empty-sequence().xs:string.xs:base64Binary.empty-sequence().
http:get('http://expath.org/xyz', map {
'status-only': true(),
@@ -722,7 +869,8 @@ The Response
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 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 Key | XDM Type | -Optional | Description |
|---|---|---|---|
| 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 @@
| message | xs:string |
- No |
HTTP reason phrase. |
@@ -781,13 +924,11 @@
| headers | map(xs:string, xs:string) |
- Yes | HTTP response header fields. |
| body | item()+ |
- Yes | HTTP response body. |
| 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 |
+
This section defines and describes the error codes that may be raised by the module.