Hi,
I’m trying to parse the headers in a response received by a Xojo.Net.HTTPSocket
to a Dictionary
. As far as I can see, the Xojo.Net.HTTPSocket
only exposes one method related to the response headers - Xojo.Net.HTTPSocket.ResponseHeader(name As Text) As Text
. This is fine if you know the name of a header (e.g: Content-Type) but is there a way to iterate through all of the response headers?
Looking at the Content
MemoryBlock
property of the Xojo.Net.HTTPSocket
instance after the page is received only seems to contain the body of the response, not the headers. The Xojo.Net.HTTPSocket.HeadersReceived
event doesn’t expose them either.
Am I overlooking something here? Surely there must be a way to get a list of all response headers?
You’d think that such a simple and seemingly obvious feature wouldn’t be overlooked during implementation but it seems to be a common theme. It was requested 16 months ago, <https://xojo.com/issue/47895>
It is easy to do that with the Classic Framework. I cannot comment for your case: I never used the New Framework.
You may start by getting the Header (put the Text in a TextArea) to know its format.
Imagine if the format is; one Header in a single line, and a space as Name / Property separator
Did you read:
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields ?
That may gives ideas.
Urgh. Just added to the Feedback case. How depressing.
[quote=404142:@Emile Schwarz]It is easy to do that with the Classic Framework. I cannot comment for your case: I never used the New Framework.
You may start by getting the Header (put the Text in a TextArea) to know its format.
Imagine if the format is; one Header in a single line, and a space as Name / Property separator
Did you read:
List of HTTP header fields - Wikipedia ?
That may gives ideas.[/quote]
Thanks but I need HTTP 1.1 so I have to use the new framework classes.
I do not think so. You can get HTTP 1.1 by setting (If I understand correctly what was said to me in this forum.
I search in my project:
Img_Socket.ConnectionType = SSLSocket.TLSv12
// (HTTPSecureSocket) in the Classic FrameWork
Of course, I may be wrong.
BTW: did you store in a TextField (or TextArea) the Text from the Headers ?
Just FYI that setting the connection type to TLSv12 does not mean you are using the HTTP 1.1 protocol on that connection.
With the classic HTTPSocket this simply means it connects using a newer security set up for the TCP/IP data transmission but is still using HTTP 1.0.
[quote=404184:@Emile Schwarz]I do not think so. You can get HTTP 1.1 by setting (If I understand correctly what was said to me in this forum.
I search in my project:
Img_Socket.ConnectionType = SSLSocket.TLSv12
// (HTTPSecureSocket) in the Classic FrameWork
Of course, I may be wrong.
BTW: did you store in a TextField (or TextArea) the Text from the Headers ?[/quote]
The classic socket doesnt offer HTTP 1.1.
I didnt store the text from the headers because no header text is provided by the new framework HTTPSocket
Thank you for the clarification.
So, I was wrong too. Sorry. I think I’d better start watching TV and stop on Xojo until tomorrow.
Funny - I was just thinking the exact opposite thing for me!