The response returned by the server to the HTTP client is copied to the HTTP response object. The response object contains the following fields:

  • INTEGER StatusCode—the HTTP response status code
  • CHARACTER StatusReason—the HTTP response status reason
  • CHARACTER ContentType—the response message content type (for example, text/xml, application/json)
  • INTEGER ContentLength—the length (in bytes/characters) of the response message
  • CHARACTER CharacterEncoding—the response message's content type encoding (for example, charset='utf-8')
  • RAW ContentMD5—an MD5 hash of the response message content
  • Progress.Lang.Object Entity—an ABL object containing the response message content
  • CHARACTER TransferEncoding—the transfer encoding used in the response message
  • CHARACTER Version—the HTTP version

The following example demonstrates how to process a response. In this example, the response message is written to a log file if the status code that is returned is 200. The response message content is extracted from the Entity property of the HTTP response object.

USING OpenEdge.Net.HTTP.*.
USING OpenEdge.Net.URI.
USING Progress.Json.ObjectModel.*.

DEFINE VARIABLE oClient AS IHttpClient NO-UNDO.
DEFINE VARIABLE oURI AS URI NO-UNDO.
DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO. 
DEFINE VARIABLE OResponse AS IHttpResponse NO-UNDO.
DEFINE VARIABLE oJsonObject AS JsonObject NO-UNDO.
DEFINE VARIABLE JsonString AS LONGCHAR NO-UNDO.

oJsonObject = new JsonObject().
LOG-MANAGER:LOGFILE-NAME = "C:\mylog.log".

oClient = ClientBuilder:Build():Client.
oURI = new URI('http', 'oemobiledemo.progress.com').
oURI:Path = "/OEMobileDemoServices/rest/CustomerService/Customer".
oURI:AddQueryString("filter=Country='Finland'").

oRequest = RequestBuilder:GET(oURI):Request.
oResponse = oClient:Execute(oRequest).

IF oResponse:StatusCode <> 200 THEN
    RETURN ERROR "Request Error: " + STRING(oResponse:StatusCode).
ELSE
    oJsonObject = CAST(oResponse:Entity, JsonObject).
    oJsonObject:Write(JsonString, true).
    LOG-MANAGER:WRITE-MESSAGE(STRING(JsonString)).
    LOG-MANAGER:WRITE-MESSAGE(oResponse:ContentType).  

Response message content types

The following table lists the object types that the response message's Entity field may contain, with the corresponding MIME and ABL object types:
Content type MIME type(s) ABL object type
TEXT text/* OpenEdge.Core.String
JSON application/json

Progress.Json.ObjectModel.JsonConstruct

XML text/xml, text/xml-external-parsed-entity, application/xml, application/xml-external-parsed-entity, application/xml-dtd

Implementation of Ccs.Common.Support.IHandleHolder

Binary (including media and PDF files) application/octet-stream, application/pdf, application/zip, application/gzip, audio/*, image/*, video/* OpenEdge.Core.ByteBucket, OpenEdge.Core.Memptr
Multipart multipart/* OpenEdge.Net.MultipartEntity

Examples of how to process different content types are provided in the following topics:

  • String response
  • JSON response
  • XML response
  • Binary response
  • Multipart response
Note:
  • Response messages with error codes such as 404 or 501 do not cause the ABL HTTP client to throw the errors. They are processed just like any other response.
  • If the HTTP client is unable to transform the response body to an object type that represents the Content-Type header (as listed in the previous table), the data is returned as bytes of type OpenEdge.Core.Memptr. The content type is changed to application/octet-stream. The original content type header returned by the server is set to X-Orig-Content-Type. You should, therefore, check the response's ContentType header as well as the ABL object type of the response's Entity property, when deciding how to handle the response.

API reference documentation

To view the list of methods that you can use on a Response object, refer to the OpenEdge.Net.HTTP.IHttpResponse reference documentation.