简体   繁体   English

在android中运行http服务器代理?

[英]Run http server proxy in android?

is it possible to create a mini HTTP server that acts as a proxy where i can recieve any requests from a webview and it will pass that request to my http proxy server running inside the app that can then view the raw contents of that request(http headers, bodies etc) and handle it from my own proxy? 是否有可能创建一个充当代理的微型HTTP服务器,在这里我可以接收来自Webview的任何请求,并将该请求传递给运行在应用程序内部的http代理服务器,然后可以查看该请求的原始内容(http标头,正文等)并通过我自己的代理进行处理?

I can see that the apahce libraries only contain objects that allow you to create requests and handle responses but not how i can create a mini http server. 我可以看到apahce库仅包含允许您创建请求和处理响应的对象,但不包含我如何创建小型http服务器的对象。

Thanks 谢谢

I don't understand the question fully so here's the question I am going to be answering. 我没有完全理解这个问题,所以这是我要回答的问题。

Is it possible to create a HTTP server that allows me to view the source code of a web page. 是否可以创建一个HTTP服务器,使我可以查看网页的源代码。

The answer is: yes. 答案是:是的。

Since I don't really develop for Android phones, I'm only going to list out what you should do. 由于我并不是真正为Android手机开发应用程序,因此只列出您应该做的事情。


So first of all you want to accept a connection from a client. 因此,首先您要接受来自客户端的连接。 Then you might want to send it back a HTML page containing a form with a website URL field. 然后,您可能希望将其发送回包含包含带有网站URL字段的表单的HTML页面。 If you set the method to POST, you will be able to make the URL of any length. 如果将方法设置为POST,则可以设置任意长度的URL。 Now your server needs to know how to receive the HTTP POST request. 现在,您的服务器需要知道如何接收HTTP POST请求。 I don't really know the HTTP well enough to tell you how the request-response is encoded. 我不太了解HTTP,无法告诉您如何对请求响应进行编码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM