Hi All,
Is there an example how to get the whole http protocol?
I would need the request, the response header and content.
I tried out to log them but I don’t know how to use the logging api right, and
I couldn’t find any example for that.
I want to the information in my application and log all the traffic.
Here is what I tried out yet.
I use: Eclipse 3.6.1 and httpclient 4.0.3
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
public class TestWireLogging {
public static void main(String[] args) throws Exception{
System.setProperty("org.apache.commons.logging.Log" ,
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire"
,"DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient"
,"ERROR");
String url = "http://google.at";
System.out.println(url);
HttpClient httpclient= new DefaultHttpClient();
HttpGet httpost = new HttpGet(url);
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
String content = EntityUtils.toString(entity);
System.out.println(content);
System.err.println("test");
}
}
If someone could give me an example,
I would be very grateful.
Thanks,
Flo
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]