Jsoup http日志记录 [英] Jsoup http logging

查看:75
本文介绍了Jsoup http日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以记录http请求和响应? 让我们假设以下请求

Is there a way to log the http request and response? Let's assume the below request

Connection.Response res = Jsoup.connect("LOGIN_URL_HERE")
            .data("user", "USER", "pass", "PASS")
            .method(Connection.Method.POST)
            .execute();

如何记录http请求和响应?请注意,我需要的是HTTP,而不仅仅是要解析的HTML.

How can I log the http request and response? Please mind that I want the HTTP and not just the HTML that will be parsed.

推荐答案

默认情况下,jsoup使用java.net.HttpURLConnection的实现,所以我想您需要为该实现打开日志记录(可能是:sun.net.www.protocol.http.HttpURLConnection)java.net

By default jsoup uses a implementation of java.net.HttpURLConnection So I suppose you need to turn on logging for that implementation (probably: sun.net.www.protocol.http.HttpURLConnection) or for java.net.

有一个系统属性可以启用对Java net utils的记录

There is a system property that will enable logging for java net utils

-Djavax.net.debug=all

这篇关于Jsoup http日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆