B4J Question jOKHttpUtils2 - How to remove unneeded headers

ranul

Member
Licensed User
Longtime User
Hi,

I am using jOKHttpUtils2.

I am calling PostString.
I need to remove the headers: "Accept-Encoding" and "User-Agent". Is it possible?

Here is my code:

B4X:
    Dim http As HttpJob
    Dim url As String
    Dim sResponse As String
  
     http.Initialize("", Me)
    url = "http://" & txtIPAddress.Text & ":" & txtTCPPort.text
    sResponse = http.PostString(url, s)
    http.GetRequest.SetContentType("application/json")
    http.GetRequest.SetHeader("Content-Length", s.Length())
    http.GetRequest.RemoveHeaders("User-Agent")
    http.GetRequest.RemoveHeaders("Accept-Encoding")

But the headers "User-Agent" and "Accept-Encoding" still sent to the server.

Thanks,
Ran
 
Last edited:

MarkusR

Well-Known Member
Licensed User
Longtime User
why do you need to remove it?

because the User-Agent is a information for the web server which browser is used ...

i think the content-length (for the payload) is set automatic and its not necessary to add.
i used also json transfer and never added it to the http header.

But the headers "User-Agent" and "Accept-Encoding" still sent to the server.
if you are sure then its a answer for erel?
 
Last edited:
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
if you request data from any http server in web its better to fake the User-Agent or you get wrong or no result.
typically you would give the user-agent a own name because it make the http request from your app, but that means
that web servers can cancel this request.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…