Android BasicHeader - 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 BasicHeader class.

This code example shows how to use the following methods:
            return this;
        } 
 
        public Builder header(final String name, final String value) {
            if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(value)) {
                this.headers.add(new BasicHeader(name, value));
            } 
            return this;
        } 
 
        public Builder headers(final List<Header> headers) {
            this.headers.addAll(headers);
            return this;
        } 
 
        public Builder id(final String id) {
            if (!TextUtils.isEmpty(id)) {
                this.params.add(new SimpleRequestParam("id", id));
            } 
            return this;
6
CodeRank
This code example shows how to use the following methods:
    /** HTTP header for url-encoded content type. */ 
    public static final Header URL_ENCODED = new BasicHeader("Content-type", 
        "application/x-www-form-urlencoded; charset=UTF-8"); 
 
    /** HTTP header for declaring allowed GZIP encoding. */ 
    public static final Header GZIP_ENCODING = new BasicHeader("Accept-Encoding", "gzip"); 
 
    /** 
     * HTTP header faking Mozilla as the user agent. 
     */ 
    public static final Header USER_AGENT_HEADER_MOZILLA = new BasicHeader("User-Agent", 
        "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7) Gecko/20011221"); 
 
    private HttpHeaders() 
    { 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
        assertNull(httpentity.getContentType());
    } 
 
    public void testContentEncoding() throws Exception { 
        HttpEntityMockup httpentity = new HttpEntityMockup();
        httpentity.setContentEncoding(new BasicHeader(HTTP.CONTENT_ENCODING, "gzip"));
        assertEquals(HTTP.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
        assertEquals("gzip", httpentity.getContentEncoding().getValue());
 
        httpentity.setContentEncoding("gzip");
        assertEquals(HTTP.CONTENT_ENCODING, httpentity.getContentEncoding().getName());
        assertEquals("gzip", httpentity.getContentEncoding().getValue());
 
        httpentity.setContentEncoding((Header)null);
        assertNull(httpentity.getContentEncoding());
        httpentity.setContentEncoding((String)null);
        assertNull(httpentity.getContentEncoding());
    } 
 
    public void testChunkingFlag() throws Exception { 
5
CodeRank
This code example shows how to use the following methods:
		HttpPost post = new HttpPost(url);
		post.setHeader("Content-Type", "application/json");
 
		try { 
		      ByteArrayEntity se = new ByteArrayEntity(json.getBytes());  
		      se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
		      post.setEntity(se);
		       
		      return httpclient.execute(post);
		} 
		catch(Exception e){
			Logger.w("Failed to send request. " +  
		    		Log.getStackTraceString(e));
		} 
		 
		return null; 
	} 
 
	@Override 
	public EasyJSONObject fetchSettings() { 
5
CodeRank
This code example shows how to use the following methods:
                new ProtocolVersion("HTTP",1,1), 400, "Unauthorized"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(pushJSON.getBytes()),
                pushJSON.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        httpResponse.setHeader(new BasicHeader(CONTENT_TYPE_KEY, CONTENT_TYPE_JSON));
 
        ScheduleAPIResponseHandler handler = new ScheduleAPIResponseHandler();
 
        try { 
            handler.handleResponse(httpResponse);
        } 
        catch (APIRequestException ex){
 
            APIError error = ex.getError().get();
            String errorMessage = error.getError();
            assertTrue("Error message incorrect", errorMessage.equals("Unauthorized"));
            return; 
        } 
        catch (Exception ex){
5
CodeRank
This code example shows how to use the following methods:
                new ProtocolVersion("HTTP",1,1), 400, "Unauthorized"));
        InputStreamEntity inputStreamEntity = new InputStreamEntity(
                new ByteArrayInputStream(errorString.getBytes()),
                errorString.getBytes().length);
        httpResponse.setEntity(inputStreamEntity);
        httpResponse.setHeader(new BasicHeader(CONTENT_TYPE_KEY,
                                               CONTENT_TYPE_TEXT_HTML));
 
        PushAPIResponseHandler handler = new PushAPIResponseHandler();
 
        try{ 
            handler.handleResponse(httpResponse);
        } 
        catch (APIRequestException ex){
            APIError error = ex.getError().get();
            assertTrue("String error message is incorrect", 
                       error.getError().equals("Unauthorized"));
            return; 
        } 
        catch (Exception ex){
5
CodeRank
This code example shows how to use the following methods:
    { 
        if (json == null || json.toString().isEmpty())
            throw new UnsupportedOperationException("JSON Content is required.");
 
        StringEntity se = setMessageBody(json.toString());
        se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, MIME_TYPE_JSON));
        if (logger.isDebugEnabled())
        { 
            logger.debug("Json string value: " + se);
        } 
        return se;
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:
 
	@Override 
	public Header getContentType() 
	{ 
		//return new BasicHeader(HTTP.CONTENT_TYPE, "application/json"); 
		return new BasicHeader(HTTP.CONTENT_TYPE, "application/json");
	}	 
} 
5
CodeRank
This code example shows how to use the following methods:
        if (transferEncodingIsPresent(response))
            return; 
 
        Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN);
        if (contentLength == null) {
            contentLength = new BasicHeader(HTTP.CONTENT_LEN, Long.toString(entity
                    .getContentLength()));
            response.setHeader(contentLength);
        } 
    } 
 
    private boolean transferEncodingIsPresent(HttpResponse response) {
        Header hdr = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
        return hdr != null;
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
    } 
 
    @Test(expected=MalformedChallengeException.class) 
    public void testEmptyHeader() throws Exception { 
        final TestAuthScheme authscheme = new TestAuthScheme();
        final Header header = new BasicHeader(AUTH.WWW_AUTH, "Test    ");
        authscheme.processChallenge(header);
    } 
 
    @Test(expected=MalformedChallengeException.class) 
    public void testInvalidHeaderValue() throws Exception { 
        final TestAuthScheme authscheme = new TestAuthScheme();
        final Header header = new BasicHeader("whatever", "whatever");
        authscheme.processChallenge(header);
    } 
 
} 
 
4
CodeRank

Related Android BasicHeader Questions & Answers:

See Code Examples for Android BasicHeader Methods: