0

I am trying to add new headers in requests/responses of webpages that are displayed in WebView.

After research, I found that the easy way to add headers is to set the user-agent header. My problem that it is working on Desktop (Linux) but it is not working on Android and iOS.

First, "getUserAgent()" method is returning null ! Second, "setUserAgent()" is not working on Android and iOS devices

6
  • ”I found that the easy way to add headers is to set the user-agent header” -> setting the user agent header has nothing to do with setting other headers in requests and responses. What other “new headers in requests and responses” do you want and why? You could edit the question to add a desired network trace, similar to a verbose curl output that includes that exact header values you want to add. Commented Sep 1, 2024 at 4:43
  • I want to send some data/tokens to the backend. and for some limitations, currently, the available way to send those tokens is to add them the the request headers. I tried many ways, until i found this x.com/CodingFabian/status/524942996748652544 this is how the user-agent can be used to add new request headers. and it is working for me in Linux env. but not working when I use GluonFX to run on Android and iOS mobiles Commented Sep 2, 2024 at 5:17
  • That twitter post: webEngine.setUserAgent("foo\nHeader: value") is just a ridiculous hack. Commented Sep 2, 2024 at 8:38
  • But I saw it worked using Desktop But overall. Then how can I add new headers to my requests :) which can be working on Desktop, Android, iOS Commented Sep 2, 2024 at 9:20
  • That’s a different question. Perhaps you could use a CookieManager to set cookies instead. It isn’t the same as setting an arbitrary header, but that is the standard way to send additional data from a client to a server with each request. Don’t know if it would apply in your case or not. Commented Sep 2, 2024 at 11:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.