简体   繁体   English

HtmlUnit修改传出请求? 怎么样?

[英]HtmlUnit modify outgoing request? how?

I'm trying to modify a request made by HtmlUnit before it gets sent out, I did a lot of Googling and found this in their FAQ 我试图在发送之前修改HtmlUnit发出的请求,我做了很多谷歌搜索,并在他们的常见问题中找到了这个

http://htmlunit.sourceforge.net/faq.html#HowToModifyRequestOrResponse http://htmlunit.sourceforge.net/faq.html#HowToModifyRequestOrResponse

How to modify the outgoing request or incoming response? 如何修改传出请求或传入响应? You can subclass HttpWebConnection and override getResponse() as: 您可以将HttpWebConnection子类化并覆盖getResponse(),如下所示:

  new WebConnectionWrapper(webClient) { public WebResponse getResponse(WebRequest request) throws IOException { WebResponse response = super.getResponse(request); // modify the response by creating a new WebResponse return response; } }; 

I'm trying to modify the request after clicking a submit button like the example below 我正在尝试在单击提交按钮后修改请求,如下例所示

page = submitButtonSend.click();

How should this be written so I can modify the outgoing request before it gets sent out? 应如何编写,以便我可以在发送之前修改传出请求?

public WebResponse getResponse(WebRequest request) throws IOException {
    modifyRequest(request);
    return super.getResponse(request);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM