Android HttpRequest - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpRequest class.

This code example shows how to use the following methods: getParams, getRequestLine
            // expected 
        } 
    } 
 
    public void testRequestLine() throws Exception { 
        HttpRequest request = new BasicHttpRequest("GET", "/stuff");
        request.getParams().setParameter(
                CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_0);
        assertEquals("GET", request.getRequestLine().getMethod());
        assertEquals("/stuff", request.getRequestLine().getUri());
        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
    } 
 
    public void testRequestLine2() throws Exception { 
        HttpRequest request = new BasicHttpRequest("GET", "/stuff", HttpVersion.HTTP_1_0);
        assertEquals("GET", request.getRequestLine().getMethod());
        assertEquals("/stuff", request.getRequestLine().getUri());
        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getProtocolVersion());
    } 
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addHeader, containsHeader, getParams
			throws HttpException, IOException { 
		if(request==null){
			throw new IllegalArgumentException("HTTP request may not be null");
		} 
		if(request instanceof HttpEntityEnclosingRequest){
			if(request.containsHeader(SOAP_Action)){
				throw new ProtocolException("SOAPAction header already present");				
			} 
			if(request.getParams().getParameter(SOAP_Action)!=null){
				request.addHeader(SOAP_Action,(String) request.getParams().getParameter(SOAP_Action));
			} 
		} 
	} 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addHeader, containsHeader
This code example shows how to use the following methods: containsHeader, getProtocolVersion, getRequestLine
 
        Assert.assertEquals(0, conn.getMetrics().getRequestCount());
 
        final HttpRequest request = conn.receiveRequestHeader();
        Assert.assertNotNull(request);
        Assert.assertEquals(HttpVersion.HTTP_1_1, request.getProtocolVersion());
        Assert.assertEquals("/", request.getRequestLine().getUri());
        Assert.assertEquals("GET", request.getRequestLine().getMethod());
        Assert.assertTrue(request.containsHeader("User-Agent"));
        Assert.assertEquals(1, conn.getMetrics().getRequestCount());
    } 
 
    @Test 
    public void testReadRequestEntity() throws Exception { 
        final String s = "POST / HTTP/1.1\r\nUser-Agent: test\r\nContent-Length: 3\r\n\r\n123";
        final ByteArrayInputStream instream = new ByteArrayInputStream(s.getBytes("ASCII"));
        Mockito.when(socket.getInputStream()).thenReturn(instream);
 
        conn.bind(socket);
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: addHeader
		 * .com/auth/userinfo.email 
		 */} 
 
	@Override 
	public void processHttpRequest(HttpRequest request) {
		request.addHeader("provider", "GoogleOpenIDConnect");
		request.addHeader("response_type", "code");
		request.addHeader("token", mToken);
 
		request.addHeader("scope", "https://www.googleapis.com/auth/userinfo.email");
	} 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android HttpRequest Questions & Answers:

Other Android HttpRequest Examples

50:	
51:				HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
52:				HttpRequest request = httpRequestFactory
53:						.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
54:				request.getUrl().put("key", API_KEY);
-
80:	
81:				HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
82:				HttpRequest request = httpRequestFactory
83:						.buildGetRequest(new GenericUrl(PLACES_DETAILS_URL));
84:				request.getUrl().put("key", API_KEY);
-
102:				final HttpTransport transport) {
103:			return transport.createRequestFactory(new HttpRequestInitializer() {
104:				public void initialize(HttpRequest request) {
105:					GoogleHeaders headers = new GoogleHeaders();
106:					headers.setApplicationName("AndroidHive-Places-Test");

Read More

See Code Examples for Android HttpRequest Methods: