Class ModifiedNetJavaImpl

java.lang.Object
gaiasky.util.ModifiedNetJavaImpl

public class ModifiedNetJavaImpl extends Object
This class is a modified version of NetJavaImpl that ensures the doInput flag is always set to true.

In the original NetJavaImpl class, the doInput flag is determined based on the HTTP method (e.g., it would be set to false for HEAD requests). However, this modification forces the flag to be always true, ensuring that the connection can read the response code and headers, even for HEAD requests.

This change allows the retrieval of HTTP status codes for HEAD requests, which are typically sent to retrieve only the headers (without the response body). By forcing doInput to be true, it ensures that the response code can always be read, while avoiding any attempts to read the body of the response (which will be empty for HEAD requests).

Note that setting doInput to true for HEAD requests does not mean the response body will be transmitted. The body is empty for HEAD requests; only the headers (including the status code) are accessible.

For all HTTP methods, this modified implementation will still handle reading and writing data to the connection as needed, but it will not fail to read the response code due to an incorrect doInput setting.

This class works well for scenarios where you need to test the connection (e.g., for checking if a URL is reachable) by sending a HEAD request, retrieving the status code, and ensuring the connection is valid.

Finally, this implementation does not create its own ThreadPoolExecutor, but uses the one provided by the main instance of GaiaSky.

See Also:
  • Constructor Details

    • ModifiedNetJavaImpl

      public ModifiedNetJavaImpl()
    • ModifiedNetJavaImpl

      public ModifiedNetJavaImpl(int maxThreads)
  • Method Details

    • sendHttpRequest

      public void sendHttpRequest(com.badlogic.gdx.Net.HttpRequest httpRequest, com.badlogic.gdx.Net.HttpResponseListener httpResponseListener)