简体   繁体   中英

How request CONNECT with Apache HttpComponents Client

Apache says:

"HttpComponents Client is a successor of and replacement for Commons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to upgrade."

In package org.apache.http.client.methods almost all Http methods are supported:

  • OPTIONS (HttpOptions)
  • GET (HttpGet)
  • HEAD (HttpHead)
  • PATCH (HttpPatch)
  • POST (HttpPost)
  • PUT (HttpPut)
  • DELETE (HttpDelete)
  • TRACE (HttpTrace)

But what is with the method CONNECT? How to execute a CONNECT request?

("Before" in org.apache.commons.httpclient there exist the ConnectMethod for method CONNECT.)

One can easily create a CONNECT request but I am not entirely sure what you intent to do with it

HttpRequest connect = new BasicHttpRequest("CONNECT", "somehost:80");

HttpClient creates CONNECT requests internally when establishing an SSL tunnel through a proxy server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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