0

I have some code that I need to migrate from commons-httpclient 3.x to httpcomponents-client 4.x (or newer). In some error handling code, there are calls to setConnectionCloseForced(true) on subclasses of HttpMethodBase, such as GetMethod or PostMethod. What would be the equivalent in httpcomponents-client 4.x?

HttpMethodBase httpMethod = /* some value */;
try {
    // do something
} catch (Exception e) {
    // handle error
} finally {
    // how to convert this?
    httpMethod.setConnectionCloseForced(true);
}
Josh Tynjala
  • 5,235
  • 3
  • 23
  • 25
  • IIRC you need to do it at the "[type]HTTPMethod" something like: `getMethod.releaseConnection();` – Jorge Campos Jan 09 '23 at 22:22
  • This thread may also be relevant: https://stackoverflow.com/questions/21574478/what-is-the-difference-between-closeablehttpclient-and-httpclient-in-apache-http – Jorge Campos Jan 09 '23 at 22:24

0 Answers0