Sunday, 15 September 2013

loadUrl and catch outgoing request headers

loadUrl and catch outgoing request headers

I want to laod the url and catch the outgoing headers that are sent with
http request, in a single request because my server accepts only one
request.
Is there any way to do this?
Right now i am loading url with webView.laodUrl() and catching headers in
another functions i-e; 2 functions right now but i want to be done in 1
funtion.
Below is what i am doing in 2 requests:
wv.loadUrl("http://" + url); /// This is First request.
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(aURL);
Header headers[] = httpget.getAllHeaders();
for(Header h : headers)
{
//something here...
}
HttpResponse response = null;
try
{
response = httpclient.execute(httpget); /// This is second request
}
catch (Exception e)
{
e.printStackTrace();
}
HttpEntity entity = response.getEntity();
headers = response.getAllHeaders();
String str_headers = "";
for(Header h : headers)
{
str_headers += h.getName() + ": " + h.getValue();
}
Kindly give me suggestions if any..
Thanks

No comments:

Post a Comment