HTTP request modification in Firefox OS [closed]

浪尽此生 提交于 2019-12-13 05:17:58

问题


I'm making an app, it just loads a website. I need to modify the user agent of the http reqeust. I also need to cancel requests made by the site if URI matches a pattern (i.e. "ads").

How can I listen/control all HTTP requests made in my app is there an API for this?


回答1:


If it's just for you you can change the user agent on the phone in the user prefs (user.js file on your phone that you can access through adb shell).

Otherwise your best option is to use a reverse proxy.

APP -> Reverse proxy -> Real website

The reverse proxy is a server application that has full control over the HTTP request and can strip off UA header or replace it with new ones etc.

Third one: Use the mozTCPSocket API to create HTTP requests to the server. If you only do GET it should not be that hard and you have full control over the request. If you only ever talk to one server it could be OK, but it'll be more work.



来源:https://stackoverflow.com/questions/25153906/http-request-modification-in-firefox-os

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!