Skip to content
Advertisement

Get page content from Apache Commons HTTP Request

So I’m using Apache Commons HTTP to make a request to a webpage. I cannot for the life of me figure out how to get the actual content from the page, I can just get its header information. How can I get the actual content from it?

Here is my example code:

JavaScript

Advertisement

Answer

Use HttpResponse#getEntity() and then HttpEntity#getContent() to obtain it as an InputStream.

JavaScript

Note that HttpClient isn’t part of Apache Commons. It’s part of Apache HttpComponents.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement