Using Apache HTTPClient - how can one see the raw request string before it's being sent?

前端 未结 4 1481
庸人自扰
庸人自扰 2020-12-15 05:29

For debugging purposes, I\'d like to see the raw request that is going to be sent. Is there a way to get this without a HTTP monitor directly from the API of HttpPost or Htt

4条回答
  •  伪装坚强ぢ
    2020-12-15 06:17

    You can set some environment variables for Apache HttpClient (example tested for 4.3.2).

    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.org.apache.http.wire", "DEBUG");
    

    There are also some more variables for debugging:

    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.impl.conn", "DEBUG");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.impl.client", "DEBUG");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.client", "DEBUG");
    System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "DEBUG");
    

提交回复
热议问题