java - TCP connection is not reused for HTTP requests with HttpURLConnection -


I have created an application that receives a request at a URL, and then downloads the full content of that page

The client sends GET for example, Stackoverflow.com, and leads a parser's response, after which there is resposability to find all the sources from the page which will later be downloaded with GET requests is required.

The method below is used to send those GET requests. It is sometimes called constant, with the URL provided by the parser. Most of those URLs are located on the same host, and TCP should be able to share the connection.

  public static zero sendGetRequestToSubObject (string reqil) {URL url = new URL (recUrl.toString ()); URL Connection Connection = url.openConnection (); InputStreamReader isr = New InputStreamReader (connection.getInputStream ()); } Every time this method is called, a new TCP connection (with a TCP 3-way handshake) is created and GET is then sent to that connection. But I want to reuse the TCP connection to improve the performance.  

I feel that whenever I make a new URL object every time in the name of the law, this is the way to work ...

Perhaps someone would do me better Can you help?

Thank you!

Comments