Page History
This Application service module contains the library of critical HTTP communication services. In here are the services that process the HTTP request, sets the relevant HTTP request header fields, sets the HTTP method, and then allows the developer to set the appropriate HTTP response header fields, status code, and body. Many of these services are called automatically from core routines (like the HTTP_MCP
controller) so that the critical HTTP request details are accessible to the developer in a very convenient manner.
Application service module that helps build responses using various JSON formats.
that provides several core services to help with HTTP request and HTTP response management.
Syntax
Code Block |
---|
Response = HTTP_Services(Service, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10) |
...
Parameter | Description |
---|---|
Service | The name of the service being requested. Required. |
Param1 - Param10 | Generic parameters. |
Remarks
The SRP HTTP Framework supports two popular JSON friendly data formats: HAL and Schema. HAL stands for Hypermedia Application Language and is an emerging format that implements the HATEOAS constraint of REST. There are other formats that are also emerging and none hold dominance at this point. Likewise, JSON itself stands alongside XML as a widely accepted general purpose format for representing resources. Therefore, if you need or prefer to use another format then you are welcome to extend HTTP_JSON_Services
(in case you want to use a different hypermedia format, such as Collection) or write a new service such as HTTP_XML_Services
(in case you want to use a different data format, such as XML).
Schema is a meta-data format. It is used to notify clients what kind of data is available, which is handy when user interfaces need to be dynamically built. Schema can be used to define if a prompt is text, numeric, date, combobox, Boolean, etc. Like HAL, Schema is also an emerging format. There are others that may be better suited to your needsThis service module contains the library of critical HTTP communication services. In here are the services that process the HTTP request, sets the relevant HTTP request header fields, sets the HTTP method, and then allows the developer to set the appropriate HTTP response header fields, status code, and body. Many of these services are called automatically from core routines (like the HTTP_MCP controller) so that the critical HTTP request details are accessible to the developer in a very convenient manner.
Services
Service | Description |
---|---|
RunHTTPService | Calls the indicated HTTP web service routine. |
Sets the self URL for the current service. The self URL is the URL that identifies itself. It is typically returned in responses to serve as a self-referencing ID apart from other URLs that might be returned which direct the caller to other services. | |
Returns the self URL for the current service. | |
Sets the HTTP request that the OECGI creates to memory so it can be retrieved by later routines. This avoids the need to pass this around into various routines. | |
Returns the original HTTP request that the OECGI creates. | |
Returns a specific HTTP request value. This is normally set within the SetOECGIRequest service. This method is not called directly as other services normally are. It is a generic service that various 'GetHTTPxxxx' services will call. This is why the meta data doesn't include GetHTTPValue but one or more specific GetHTTPxxxx options. | |
Sets all of the Request Header Fields based on the content of the HTTP request that the OECGI creates. This assumes the SetOECGIRequest service has already been called so that the Request array is in memory. | |
Sets the indicated Request Header Field with the indicated value. This can then be retrieved with a GetRequestHeaderField service call so that server processing can operate accordingly. | |
Returns all of the Request Header Field names and values. These are formatted as Name : <space> Value <crlf> with an extra <crlf> appended after the last field/value pair. | |
Returns the value previously set for the indicated Request Header Field. The Name argument is case-insensitive but if the indicated Request Header Field has not been set then an error condition will be set. | |
Sets all of the Query Fields based on the content of the HTTP request that the OECGI creates. This assumes the SetOECGIRequest service has already been called so that the Request array is in memory. | |
SetQueryField | Sets the indicated Query field with the indicated value. This can then be retrieved with a GetQueryField service call so that server processing can operate accordingly. |
GetQueryField | Returns the value previously set for the indicated Query Field. If then indicated Query Field has not been set then then an error condition will be set. |
SetResponseHeaderField | Sets the indicated Response Header Field with the indicated value. This can then be retrieved with a GetRequestHeaderField service call so that server processing can operate accordingly. |
GetResponseHeaderFields | Returns all of the Response Header Field names and values. These are formatted as Name : <space> Value <crlf> with an extra <crlf> appended after the last field/value pair. This also returns the response status since the CGI specification uses the "Status" header field. This will be put into the response before the regular header field/values. |
GetResponseHeaderField | Returns the value previously set for the indicated Response Header Field. The Name argument is case-insensitive but if the indicated Response Header Field has not been set then it an error condition will be set. |
SetResponseStatus | Sets the HTTP status code to be used in the response. This can be set at any time. If unchanged by other routines this will be the status code used. |
GetResponseStatus | Gets the current HTTP status code to be used in the response. If this has not yet been set then code 200 (OK) will be used as a default. |
SetResponseBody | Sets the body content to be returned in the response. |
GetResponseBody | Gets the current body to be returned in the response. |
GetResponseBodyIsBinary | Gets the binary flag associated with the current body. This is normally set by the SetResponseBody service at the time the body content is also set. |
GetResponse | Gets the full response, headers and body, to be returned to the HTTP request. This will build the response as needed by OECGI, especially regarding binary data handling. |
GetErrorResponse | Creates and returns an error response. This is intended to be used when there is no response body to return to the client. This response will contain the current response status and any error information stored using Error_Services. |
DecodePercentString | Decodes the string so that percent-encoded characters are restored to their regular form. This returns the decoded string. |
ClearSettings | Clears all of the global common variables used to track header names, values, and the status settings. This will typically only be called within HTTP_MCP when the response is finished and sent back to the OECGI. |
GetHomeURL | Returns the Home URL for the web site. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <1>. |
GetAPIRootURL | Returns the API Root URL for the web site. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <2>. |
GetCapturePath | Returns the capture path for the request and response content. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <3> |
GetEnableAuthenticationFlag | Returns the enable authentication flag setting. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <4>. Note: Only an explicit setting of False (0) will turn this flag off. |
GetRealmValue | Returns the realm value, which is used by the WWW-Authenticate response header. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <5>. |
GetEntryPointService | Returns the entry point service name. It pulls this from SRP_HTTP_FRAMEWORK_SETUP <6>. Default is entry_point. |
GetVersion | A carriage-return/line-feed character will be used to separate the two pieces of information. |
GetFullEndPointURL | Returns the full URL for the end point. This should correspond with the URL requested by the client. |
...