简体   繁体   English

如何使用HtmlUnit发布HEAD请求?

[英]How to post HEAD request with HtmlUnit?

How can I use existing WebClient to post a custom HEAD request? 如何使用现有WebClient发布自定义HEAD请求? Ie there is no form on the page, I want to set request properties manually. 即页面上没有表单,我想手动设置请求属性。

Use WebClient#getPage() where you pass the WebRequestSettings in which you can construct with a HttpMethod of HEAD . 使用WebClient#getPage() ,您可以在其中传递可以使用HEADHttpMethod 构造WebRequestSettings

Thus, basically: 因此,基本上:

Page page = webClient.getPage(new WebRequestSettings(new URL("http://stackoverflow.com"), HttpMethod.HEAD));

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

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