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

前端 未结 4 1482
庸人自扰
庸人自扰 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:15

    Try this:

    HttpClient client = new HttpClient();
    PostMethod method = new PostMethod(url);
    
    method.setParameter(...., ....);
    

    to retrieve the URI

    System.out.println("getUri: " + method.getURI());
    

    to retrieve the parameters in POST

    method.getRequestEntity().writeRequest(System.out);
    

提交回复
热议问题