Capture the Android's browser HTTP petitions

by psaltamontes » Fri, 19 Jun 2009 02:43:42 GMT

Sponsored Links

I need capture the Android's browser HTTP petitions.

The idea is to use a service that listen a localport (7777). This
service modify the HTTP petition and sends this petition to Internet.

In PC to capture the HTTP petitions is easy, I change the browser
configuration, I put localhost and a port (7777) and it's works. But,
in Android I don't know how to change the browser configuration.

I think that in "/data/data/" there are the
configuration files of the browser, but I don't know if I can
configure the proxy browser.

Any idea?


Capture the Android's browser HTTP petitions

by psaltamontes » Fri, 19 Jun 2009 22:58:08 GMT

 Yes, I want to say request :), sorry , I need improve my English.

I don't want my application modify the settings of the browser, the
idea is that the user configure the proxy of the browser and install
my application. This application is a service that listen the HTTP
requests and send to the Internet.

I want capture the HTTP request and modify the headers because, in the
header, I put a number to identify the client that connect to my
webserver, doing this, the user don't have to put an user name and a
password. I have written the code to do this, in PC works, but in
Android I don't know how to get this behaviour.

How can I do?


Sponsored Links

Capture the Android's browser HTTP petitions

by psaltamontes » Fri, 19 Jun 2009 23:34:52 GMT

 Do you know/think if this option will be in the future?

Now, I'm trying to do something with a webview and webviewclient. But
I don't know how to send a "RAW HTTP request" using these classes.

I can send/receive RAW HTTP with sockets, but I don't know how to link
these sockets with the webview.

Any idea?



Capture the Android's browser HTTP petitions

by psaltamontes » Sat, 20 Jun 2009 00:44:30 GMT


Capture the Android's browser HTTP petitions

by Alexey Krasnoriadtsev » Sun, 21 Jun 2009 00:40:00 GMT

 You can create your own Browser application, that will allow proxy
configuration. You can also take original Browser app as the base
(it's available in git).

Those users who need proxy will be able to install your browser
application and use it.


Capture the Android's browser HTTP petitions

by Hamy » Sun, 21 Jun 2009 02:18:54 GMT

 Sorry, realized right after I sent that that the imports might be


import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;


Capture the Android's browser HTTP petitions

by Hamy » Sun, 21 Jun 2009 02:28:34 GMT

 ot sure if this will help, but I hope so. This is code I found in an
application my research group is working on, and it is under apache v2


final HttpClient c = new DefaultHttpClient();
final HttpPost post = new HttpPost(SERVER + PATH);

StringBuffer params = new StringBuffer();

// Create the parameter string
params.append("type=accident&user="+androidid+"&time="+ timeStr
+ lat + "&lon="+lon);

// Add the parameters
parameter string: "
+ params);

// Do it
Log.i(LOG_LABEL, LOG_MSG_PREFIX + "Executing post to " + SERVER
Log.d(LOG_LABEL, LOG_MSG_PREFIX + "Spawning thread for HTTP
new Thread(new Runnable() {

public void run() {
HttpResponse resp = null;
try {
resp = c.execute(post);
ByteArrayOutputStream bao = new
"Response from server: "
+ new
} catch (ClientProtocolException e) {
"ClientProtocolException executing post: "
+ e.getMessage());
} catch (IOException e) {
+ "IOException writing
to ByteArrayOutputStream: "
+ e.getMessage());
} catch (Exception e) {
+ "Other Exception of
type:" + e.getClass());
message is: "
+ e.getMessage());

if (resp != null &&
resp.getStatusLine().getStatusCode() == 200) {;


Capture the Android's browser HTTP petitions

by psaltamontes » Mon, 22 Jun 2009 04:02:35 GMT

 @Alexey :

What's the meaning of "git"?

@ Hamy :

 I needed this line :) ! -> resp.getEntity().writeTo(bao);

I'm sure that the code that you are put help me a lot.

@ Raphael :

I used Google before put my question here.

If you search this --> +proxy+for+android+web+browser

The information that Google found is about change the "general/main"
proxy, I only want redirect the browser's traffic.

Thank you people.


Capture the Android's browser HTTP petitions

by Alexey Krasnoriadtsev » Tue, 23 Jun 2009 01:17:29 GMT

 GIT is the repository where all android code is.
for Browser, here is the specific link: ;a=summary


Capture the Android's browser HTTP petitions

by psaltamontes » Tue, 23 Jun 2009 03:49:55 GMT

 hen I think that I'm near to do that I want, there is something that
not works :(.

I have achieved send my modified HTTP request! Well, it works, but
only the first time :).

I have used the WebView, DefaultHttpClient, HttpGet and HttpResponse
classes to do it.

WebView : to see the webpages.
DefaultHttpClient : to send the request.
HttpGet : to do the request and add my header (.addHeader())
HttpResponse : to store the response.

When I have the web server response I send to the WebView, I use

WebView.loadDataWithBaseURL : to load the response, and here is my
problem. If the page has images, for example, the method sends HTTP
GET request. This is OK, but the problem is that the petitions don't
have my header and the server don't accept.

Is possible to modify the petitions that loadDataWithBaseURL does?

@ Alexey :

I have download the browser, this code is complicated for me. I don't
know where to begin. But I will look calmly.

On 22 jun, 19:17, Alexey Krasnoriadtsev <>

Capture the Android's browser HTTP petitions

by psaltamontes » Mon, 29 Jun 2009 23:19:06 GMT

  found the solution to capture the requests, I have to put in the
baseUrl parameter the address of the android proxy.

webview.loadDataWithBaseURL(String baseUrl, String data, String
mimeType, String encoding, String failUrl)

For example, if the android proxy service is listening the port 8282,
the baseUrl parameter will be ( : is the
emulator localhost address). loadDataWithBaseURL sends the requests to
this address and then my proxy can process the request.

On 22 jun, 21:49, psaltamontes <> wrote:

Other Threads

1. SSL KeyStore

I have the same problem with android m5-rc15.
Which TLS key formats are supported by the android api?

thanks for answers!

On Mar 23, 6:09 am, "Jonathan Thompson" <[EMAIL PROTECTED]>


2. Using notifications to switch between different already opened activities

Hi all,


I am working on an IM application for android. Currently I have one main
activity showing a list of contacts and another activity (let's call it
ChatActivity) for handling conversation.

When the user starts a chat with a contact I open the chat activity with
the startActivity firing an Intent using ACTION_VIEW as action and
CATEGORY_DEFAULT as category with a sessionId as intent data expressed
as a content URI (in my own format content://userId#<IdValue>).

When a second user receives a chat message, a notification is shown in
the status bar. When it clicks on the notification the same intent
described before is fired to start the ChatActivity.


ChatActivity is registered in manifest using the following intent



                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT"

                <data android:scheme="content"/>



When the user clicks on the notification the right activity is started.
But when a new user launches a new message and a second notification is
added to statusbar and the user is not able to open his new chat
activity if the first one is already opened.

Basically, I'm not able to use the notifications on the statusbar to be
able to switch between different already opened conversation activities
(as using alt+tab on windows). It would be great if it was possible to
do so in some way.


What's wrong with my approach?

Have you got any suggestion?


Please help!


Thanks a lot and best regards,




3. Progress bar problem

4. Unpleasant interaction between timer and updating a map overlay

5. Extract focus color from theme

6. Is it possible to create file in /system/media directory..

7. m5 not working