Salesforce

Can the HTTP Client objects be reused with each request?

« Go Back

Information

 
TitleCan the HTTP Client objects be reused with each request?
URL Namecan-the-http-client-objects-be-reused-with-each-request
Article Number000125367
EnvironmentProduct: OpenEdge
Version: 11.x, 12.x
OS: All supported platforms
Other: N/A
Question/Problem Description
Can the HTTP Client objects be reused with each request?
Can the HTTP Client objects be reused with each request in the same ABL procedure?
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The same variable can be used for multiple requests or responses. In the example code below, there's a one variable for requests and one for responses. In the second (and subsequent) calls to the RequestBuilder and the client's Execute(), new objects are created ; the previous value is 'let go' and the AVM's garbage collector evaluates whether it can be cleaned up.

If the DynObjects.Class logging is turned on, the GC at work could be seen, by the Deleted-by-GC entries, similar to the below line:

DYNOBJECTS Deleted-by-GC Progress.Lang.Object Handle:1004
 
using OpenEdge.Net.HTTP.*.
using Progress.Json.ObjectModel.*.

def var hc as IHttpClient.
def var req as IHttpRequest.
def var resp as IHttpResponse.

// create one isntance of the HTTP client
hc = ClientBuilder:Build():Client.

// each request gets its own IHttpRequest and IHttpResponse objects
// get from server
req = RequestBuilder:Get('http://httpbin.org/get'):Request.
resp = hc:Execute(req).

message
'internal handle: req ' int(req) ' resp: ' int(resp) skip
resp:StatusCode
resp:ContentType
view-as alert-box.

// post to server
req = RequestBuilder:Post('http://httpbin.org/post', new JsonObject()):Request.
resp = hc:Execute(req).

message
'internal handle: req ' int(req) ' resp: ' int(resp) skip
resp:StatusCode
resp:ContentType
view-as alert-box.

 
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 6:55 AM

Powered by