Search Results

Search found 4 results on 1 pages for 'httpurirequest'.

Page 1/1 | 1 

  • Interrupt an Http Request blocked in read() on Android

    - by twk
    Using the Apache Http stack on Android, I'm trying to force a thread out of a call to read. This is what the stack looks like: OSNetworkSystem.receiveStreamImpl(FileDescriptor, byte[], int, int, int) line: not available [native method] OSNetworkSystem.receiveStream(FileDescriptor, byte[], int, int, int) line: 478 PlainSocketImpl.read(byte[], int, int) line: 565 SocketInputStream.read(byte[], int, int) line: 87 SocketInputBuffer(AbstractSessionInputBuffer).fillBuffer() line: 103 SocketInputBuffer(AbstractSessionInputBuffer).read(byte[], int, int) line: 134 IdentityInputStream.read(byte[], int, int) line: 86 EofSensorInputStream.read(byte[], int, int) line: 159 Fetcher.readStream() line: 89 I've tried InputStream.close(), Thread.Interrupt(), and HttpUriRequest.abort(), without any success. Any ideas? I'm also open to some kind of non-blocking IO, but I don't see any way to do that with the HttpUriRequest object. Thanks!

    Read the article

  • Apache HttpClient CoreConnectionPNames.CONNECTION_TIMEOUT does nothing ?

    - by Maxim Veksler
    Hi, I'm testing some result from HttpClient that looks irrational. It seems that setting CoreConnectionPNames.CONNECTION_TIMEOUT = 1 has no effect because send request to different host return successfully with connect timeout 1 which IMHO can't be the case (1ms to setup TCP handshake???) Am I misunderstood something or is something very strange going on here? The httpclient version I'm using as can be seen in this pom.xml is <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.0.1</version> <type>jar</type> </dependency> Here is the code: import java.io.IOException; import java.util.Random; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.CoreConnectionPNames; import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; public class TestNodeAliveness { private static Logger log = Logger.getLogger(TestNodeAliveness.class); public static boolean nodeBIT(String elasticIP) throws ClientProtocolException, IOException { try { HttpClient client = new DefaultHttpClient(); // The time it takes to open TCP connection. client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 1); // Timeout when server does not send data. client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 5000); // Some tuning that is not required for bit tests. client.getParams().setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false); client.getParams().setParameter(CoreConnectionPNames.TCP_NODELAY, true); HttpUriRequest request = new HttpGet("http://" + elasticIP); HttpResponse response = client.execute(request); HttpEntity entity = response.getEntity(); if(entity == null) { return false; } else { System.out.println(EntityUtils.toString(entity)); } // Close just in case. request.abort(); } catch (Throwable e) { log.warn("BIT Test failed for " + elasticIP); e.printStackTrace(); return false; } return true; } public static void main(String[] args) throws ClientProtocolException, IOException { nodeBIT("google.com?cant_cache_this=" + (new Random()).nextInt()); } } Thank you.

    Read the article

  • Scala and HttpClient: How do I resolve this error?

    - by Benjamin Metz
    I'm using scala with Apache HttpClient, and working through examples. I'm getting the following error: /Users/benjaminmetz/IdeaProjects/JakartaCapOne/src/JakExamp.scala Error:Error:line (16)error: overloaded method value execute with alternatives (org.apache.http.HttpHost,org.apache.http.HttpRequest)org.apache.http.HttpResponse <and> (org.apache.http.client.methods.HttpUriRequest,org.apache.http.protocol.HttpContext)org.apache.http.HttpResponse cannot be applied to (org.apache.http.client.methods.HttpGet,org.apache.http.client.ResponseHandler[String]) val responseBody = httpclient.execute(httpget, responseHandler) Here is the code with the error and line in question highlighted: import org.apache.http.client.ResponseHandler import org.apache.http.client.HttpClient import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.BasicResponseHandler import org.apache.http.impl.client.DefaultHttpClient object JakExamp { def main(args : Array[String]) : Unit = { val httpclient: HttpClient = new DefaultHttpClient val httpget: HttpGet = new HttpGet("www.google.com") println("executing request..." + httpget.getURI) val responseHandler: ResponseHandler[String] = new BasicResponseHandler val responseBody = httpclient.execute(httpget, responseHandler) // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ println(responseBody) client.getConnectionManager.shutdown } } I can successfully run the example in java...

    Read the article

  • Java HTTP Client Request with defined timeout

    - by Maxim Veksler
    Hello, I would like to make BIT (Built in tests) to a number of server in my cloud. I need the request to fail on large timeout. How should I do this with java? Trying something like the below does not seem to work. public class TestNodeAliveness { public static NodeStatus nodeBIT(String elasticIP) throws ClientProtocolException, IOException { HttpClient client = new DefaultHttpClient(); client.getParams().setIntParameter("http.connection.timeout", 1); HttpUriRequest request = new HttpGet("http://192.168.20.43"); HttpResponse response = client.execute(request); System.out.println(response.toString()); return null; } public static void main(String[] args) throws ClientProtocolException, IOException { nodeBIT(""); } } -- EDIT: Clarify what library is being used -- I'm using httpclient from apache, here is the relevant pom.xml section org.apache.httpcomponents httpclient 4.0.1 jar

    Read the article

1