Entering content frameFunction documentation Accessing Header Fields Locate the document in its SAP Library structure

Use

Using GET_HEADER_FIELD() / GET_HEADER_FIELDS(), the HTTP request handler can access all attributes of the HTTP header (name/value pairs). Examples are the attributes content-length and content-type.

The methods SET_HEADER_FIELD() and SET_HEADER_FIELDS() can be used to modify the request header, if necessary (for example, if the HTTP client role is active, or if a request requires additional information or has to be sent back).

Caution

There are header fields that should not be set with method SET_HEADER_FIELD(. The description of the individual header fields explains how you should access them.

The methods mentioned above can be used to access all HTTP header fields that are sent as part of a request. The fields can be addressed by means of their case-insensitive names (for example, content-type for the content type attribute of the HTTP header). For a list of typical fields in the HTTP header, see the HTTP/1.1 specification.

In addition to these fields, there are a number of other fields that are not pure field attributes of the HTTP header, but that can be derived from the HTTP request line. These fields are known as pseudo header fields. A typical example is the query string part of a URL, or the method of the request (for example, GET or POST). Pseudo header fields are differentiated from genuine header fields by the prefix ~ (tilda) in their names (for example, ~query_string).

Functions

The following SAP-specific HTTP header fields have been added in the framework of SAP Web Application Server. These fields are only used in the HTTP request object and can be called using the method IF_HTTP_REQUEST~GET_HEADER_FIELD(). The fields contain server-specific environmental information obtained either directly or indirectly from the HTTP request, but which are not covered by the standard HTTP header fields. Most fields are called environment variables, in line with the Common Gateway Interface (CGI).

All header fields are case-insensitive and start with the reserved character "~".

The interface IF_HTTP_HEADER_FIELDS_SAP provides pre-defined string constants for all SAP-specific header fields.

Note

The SAP header fields that are written in italics should not be changed with method SET_HEADER_FIELD()! The access type is specified at the end of the description.

Header Field Name

Description

~content_data

In the case of multipart entities (for example, when uploading files from HTML forms), contains the body of the non-binary multipart segment.

~content_disposition

In the case of multipart entities, for example, when uploading files from HTML forms, contains the content disposition (segment type, segment name (filename of the segment)).

Note Do not change this value! You can use method GET_HEADER_FIELD() to query the value.

~content_filename

In the case of multipart entities when uploading files from HTML forms, contains the file name as it was entered in the HTML form or selected from the choose file dialog.

Note Do not change this value! You can use method GET_HEADER_FIELD() to query the value.

~content_name

In the case of multipart entities for HTML forms, contains the name of the input field or HTML control. The value of this field or control can be obtained from ~content_data for the same entity

Note Do not change this value! You can use method GET_HEADER_FIELD() to query the value.

~path

Contains the escaped path name from the request URI or URL (without query string), for example, "/sap/bc/bsp/sap/it00/default.htm" from "/sap(XYasfduy===)/bc/bsp/sap/it00/default.htm?x=1&y=2". Compare with ~path_translated and ~path_translated_expanded.

~path_info

Within a HTTP request handler (see interface IF_HTTP_EXTENSION), contains the URL suffix that comes after the URL prefix. The URL prefix is used to execute the request handler. This results in:

~script_name + ~path_info = ~path_translated

Example

If the request handler is registered under the URL "/sap/bc/bsp" (see transaction Using the ICF), this variable has the value "/sap/it00/default.htm" for the request URL "/sap/bc/bsp/sap/it00/default.htm".

If an internal or an external alias, for example, "myApp", points to "/sap/bc/bsp/sap", and if a request using this alias is used to gain access, then this variable is set to the value "/it00/default.htm" (see ~path_info_expanded). The request would then read "/myApp/it00/default.htm".

~path_info_expanded

Within a HTTP request handler (see interface IF_HTTP_EXTENSION), contains the URL suffix that comes after the expanded URL prefix. The URL prefix is used to execute the request handler. This results in:
~script_name_expanded + ~path_info_expanded = ~path_translated_expanded

Example

If the request handler is registered under the URL "/sap/bc/bsp" (see transaction SICF), this variable has the value "/sap/it00/default.htm" for the request URL "/sap/bc/bsp/sap/it00/default.htm".

If an internal or an external alias, for example, "myApp", points to "/sap/bc/bsp/sap", and if a request using this alias is used to gain access, then this variable is set to the value "/sap/it00/default.htm" (see ~path_info). The request would then read "/myApp/it00/default.htm".

~PATH_TRANSLATED

Contains the unescaped path name from the request URI or URL (without query string), for example, "/sap/bc/bsp/sap/it00/default.htm" from "/sap(XYasfduy===)/bc/bsp/sap/it00/default.htm?x=1&y=2". Compare with ~path_translated and ~path_translated_expanded.

~path_translated_expanded

Contains the expanded, unescaped path name that is derived from the request URI or URL when the internal or external aliases are resolved.

Example

If an internal or an external alias, for example, "myApp", points to "/sap/bc/bsp", and if a request using this alias is used to gain access, then this variable is set to the value "/sap/bc/bsp/sap/it00/default.htm". The request would then read "/myApp(XZasfduz===)/sap/it00/default.htm".

~query_string

Contains the URL-escaped query string from the request URI of a HTTP request, that is, the string part after the first question mark, for example, "name=Walt+Whitman&street=Oxford+Street" from "http://server:8080/sap/bc/ping? name=Walt+Whitman&street=Oxford+Street".

Note If you want to change the query string, set the individual form fields. To do this, use methods SET_FORMFIELD or SET_FORMFIELDS of interface IF_HTTP_ENTITY.

~remote_addr

Contains the IP address of the HTTP client if the server is accessed without a HTTP proxy, otherwise contains the IP address of the last proxy in the chain of proxies outside the server.

~request_line

Contains the complete HTTP request line of the request, for example, "GET /sap/bc/ping?param=2 HTTP/1.1"

Note If you want to make changes to the request line, use the corresponding methods for manipulating the individual components of the request line.

~request_method

Contains the HTTP method from the HTTP request line of the request, for example, "GET", "POST" or "PUT".

~request_uri

Contains the complete URI from the HTTP request line of the request, for example, "/sap/bc/ping?param=2" from "GET /sap/bc/ping?param=2 HTTP/1.1".

Note If you want to make changes to the request URI, use the corresponding methods for manipulating the individual components of the request line.

~response_line

Contains the complete HTTP response line (status line) of a received HTTP response, for example, "HTTP/1.1 200 OK".

Note If you want to make changes to the response line, use the corresponding methods for manipulating the individual components of the response line.

~script_name

Within a HTTP request handler (see interface IF_HTTP_EXTENSION), contains the URL prefix that is used to execute the request handler.

If the request handler is registered under the URL "/sap/bc/bsp" (see transaction SICF), this variable has the value "/sap/bc/bsp" for the request URL "/sap/bc/bsp/sap/it00/default.htm".

If an internal or an external alias, for example, "myApp", points to "/sap/bc/bsp", and if a request using this alias is used to gain access, then this variable is set to the value "/myApp" (see ~script_name_expanded ). The request would then read "/myApp/sap/it00/default.htm".

~script_name_expanded

Within a HTTP request handler (see interface IF_HTTP_EXTENSION), contains the URL prefix that is used to execute the request handler.

Example

If the request handler is registered under the URL "/sap/bc/bsp" (see transaction SICF), this variable has the value "/sap/bc/bsp" for the request URL "/sap/bc/bsp/sap/it00/default.htm".

If an internal or an external alias, for example, "myApp", points to "/sap/bc/bsp", and if a request using this alias is used to gain access, then this variable is not set to the value "/myApp", unlike in the case of the variable ~script_name, but is set to the expanded prefix "/sap/bc/bsp". The request would then read "/myApp/sap/it00/default.htm".

~server_name

Contains the name of the server that received the request.

~server_port

Contains the number of the port on which the request came in.

~server_protocol

Contains the protocol from the HTTP request line, for example, "HTTP/1.0" or "HTTP/1.1".

~status_code

In the case of a HTTP response (client), contains the HTTP status code, for example, 200 (OK).

Note Do not use method SET_HEADER_FIELD() to set the HTTP status. Use method SET_STATUS() of interface IF_HTTP_RESPONSE.

~status_reason

In the case of a HTTP response (client), contains the description text of the HTTP status code, for example, "OK" or "Not found" (401). The interface IF_HTTP_STATUS contains a list of all status texts in the form of constants.

Note Do not use method SET_HEADER_FIELD() to set the HTTP status. Use method SET_STATUS() of interface IF_HTTP_RESPONSE.

~uri_scheme

Contains the URI scheme of the URL, for example, "http" or "https".

To be more exact: The field contains the string that is at the beginning of the URL before the ://. This must not be the protocol that is used when working with proxies.

Note It is not recommended that you use this field to differentiate between HTTP and HTTPS! If you want to query whether it is an HTTPS connection, use attribute SSL_ACTIVE of the server object (see also IF_HTTP_SERVER).

 

See also:

The HTTP header fields are defined in interface IF_HTTP_HEADER_FIELDS with initial values, the SAP-specific header fields are in the interface IF_HTTP_HEADER_FIELDS_SAP.

 

 

Leaving content frame