How to pull Header data from HttpResponse

Posted by Mike_M_Carlson on 30-Apr-2019 13:11

How do I get information out of the header in a response?

Using ClientBuilder, I get the successful response, but the piece of data I need is in the header. Specifically the Location field.

This is what it looks like in response-data-received.txt.

HTTP/1.1 201 Created

Cache-Control: no-cache

Pragma: no-cache

Content-Length: 286

Content-Type: text/xml; charset=utf-8

Expires: -1

Location: This_is_the_information_you_need

X-Content-Type-Options: nosniff

Server: WWW Server/1.1

X-XSS-Protection: 1; mode=block

Date: Mon, 29 Apr 2019 21:17:50 GMT

 

<?xml version='1.0' encoding='utf-8'?>     

 

I can cast the response, which shows up as a WidgetHandle, to LONGCHAR but that only returns the XML part. Which is not what I need.

        DEFINE VARIABLE hxmldoc AS HANDLE NO-UNDO.

        hxmldoc = cast(oResponse:Entity, WidgetHandle):VALUE.

        hxmldoc:SAVE ("longchar", cRsp).

Thank you,

Mike

Posted by Mike_M_Carlson on 30-Apr-2019 13:25
Posted by bronco on 30-Apr-2019 13:38

A bit too fast, oResponse:GetHeader("Location") returns an OpenEdge.Net.HTTP.HttpHeader object which has a Name and Value property.

So, the location you're looking for is:

oResponse:GetHeader("Location"):Value

All Replies

Posted by Mike_M_Carlson on 30-Apr-2019 13:25
Posted by bronco on 30-Apr-2019 13:31

use: oResponse:GetHeader("Location").

Posted by bronco on 30-Apr-2019 13:38

A bit too fast, oResponse:GetHeader("Location") returns an OpenEdge.Net.HTTP.HttpHeader object which has a Name and Value property.

So, the location you're looking for is:

oResponse:GetHeader("Location"):Value

Posted by Mike_M_Carlson on 30-Apr-2019 13:44
This thread is closed