HttpRequest and HttpResponse System Entities
Introduction
HttpRequest is a system entity that represents a request to a server. HttpResponse represents the response from the server. Use these entities when publishing or consuming REST services.
HttpRequest
The HttpRequest entity has the following attributes:
| Attribute | Type | Default Value | Description |
|---|---|---|---|
HttpVersion (Inherited from HttpMessage) |
String | HTTP/1.1 | The protocol version. You can almost always ignore this value. |
Uri |
String | empty | The full URI for the incoming request, including query parameters. |
Content (inherited from HttpMessage) |
String | empty | The body of the request. |
You can retrieve the request headers via the HttpHeaders association.
HttpResponse
The HttpResponse entity has the following attributes:
| Attribute | Type | Default Value | Description |
|---|---|---|---|
HttpVersion (inherited from HttpMessage) |
String | HTTP/1.1 | The protocol version. You can almost always ignore this value. |
StatusCode |
Integer | 200 | The HTTP status code returned by the server. |
ReasonPhrase |
String | OK | A textual representation of the StatusCode. |
Content |
String | empty | The body of the response. |
For more information on HTTP status codes, see the W3C Specification of Status Code Definitions.
You can retrieve or create response headers via the HttpHeaders association.
An important HttpResponse header is Content-Type, which indicates how the content should be interpreted. For more information on this header, see the W3C specification of Content-Type.
HttpHeader
The HttpHeader entity has the following attributes:
| Attribute | Type | Default Value | Description |
|---|---|---|---|
Key |
String | empty | Header key. |
Value |
String | empty | Header value. |
Why Does Setting ReasonPhrase Have No Effect?
The HTTP/1.x protocol allowed servers to include a reason phrase in the response, including non-standard ones. In HTTP/2, reason phrases have been removed. Many web servers (including the one Mendix Runtime uses), do not allow setting anything other than the default reason phrase for the status code (even in HTTP/1.x, which technically allows it).
As a result, the ReasonPhrase attribute is only useful for reading.