B4J Question [SOLVED] Values in headers from OkHttpResponse wrapped in [ and ]

Sandman

Expert
Licensed User
Longtime User
When I grab the headers from an OkHttpResponse and get a value from it, the value is wrapped in [ and ], which isn't what the server sent.

Example response from server:
Server headers:
HTTP/1.1 200 OK
Host: 192.168.50.13:8100
Date: Mon, 09 May 2022 09:47:07 +0000
Connection: close
X-Powered-By: PHP/7.1.33-44+0~20211119.61+debian10~1.gbp448fbe
Cache-Control: no-cache
Date: Mon, 09 May 2022 09:47:07 GMT
Content-Type: text/html; charset=UTF-8

And when I grab the value of one of the headers...
Getting header:
Dim headers As Map = Response.GetHeaders
Log(headers.Get("x-powered-by"))

...it's wrapped in [ and ], like so:
Log:
[PHP/7.1.33-44+0~20211119.61+debian10~1.gbp448fbe]

It's obviously not difficult to peel off the [ and ], but I'm wondering if I'm missing something obvious? I expect to get the actual value, not the value with a little something added in the front and back.

I thought I'd ask before reporting this as a bug.
 
Solution
You´ll get a LIST of matching headers.

B4X:
Dim list1 As List
list1 = response.GetHeaders.Get("x-powered-by")
For i = 0 To list1.Size - 1
  Log(list1.Get(i))
Next

DonManfred

Expert
Licensed User
Longtime User
You´ll get a LIST of matching headers.

B4X:
Dim list1 As List
list1 = response.GetHeaders.Get("x-powered-by")
For i = 0 To list1.Size - 1
  Log(list1.Get(i))
Next
 
Upvote 1
Solution

Sandman

Expert
Licensed User
Longtime User
For the benefit of the rest of the forum: What DonManfred said here is that the header value isn't a string, but a list. That's the obvious thing I missed.
 
Upvote 0
Top