B4J Question get http headers

Pedro Caldeira

Active Member
Licensed User
Longtime User
Hello,
I need to get the http headers in a POST to a servive.
I found a similar thread with this problem in B4A, and there was a request to add that function to the lib http2utils
Is there any way to read http headers in B4J ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
In exactly the same way as in B4A. OkHttpUtils2 source code is available here: https://www.b4x.com/android/forum/t...putils2-httputils2-source-code.82632/#content

Change hc_ResponseSuccess to:
B4X:
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
   Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
     True, TaskId)
   Dim job As HttpJob = TaskIdToJob.Get(TaskId)
   job.Tag = Response.GetHeaders
End Sub
 
Upvote 0

Pedro Caldeira

Active Member
Licensed User
Longtime User
thanks you Erel. Worked.
I had to tweak it a little, since I want the headers even if there's any error. but its done.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…