AbstractHttpMessage addHeader - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AbstractHttpMessage addHeader method.

This code example shows how to use the following methods:setEntity, addHeader, setParams
    try { 
      Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null"));
      client                 = constructHttpClient(context, parameters);
      URI targetUrl          = new URI(parameters.getMmsc());
      HttpHost target        = new HttpHost(targetUrl.getHost(), targetUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);
      HttpPost request       = new HttpPost(parameters.getMmsc());
      ByteArrayEntity entity = new ByteArrayEntity(mms);
 
      entity.setContentType("application/vnd.wap.mms-message");
 
      request.setEntity(entity);
      request.setParams(client.getParams());
      request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic");
//      request.addHeader("x-wap-profile", "http://www.htcmms.com.tw/Android/Common/nexusone/ua-profile.xml"); 
      request.addHeader("x-wap-profile", "http://www.google.com/oha/rdf/ua-profile-kila.xml");
      HttpResponse response = client.execute(target, request);
      StatusLine status     = response.getStatusLine();
 
      if (status.getStatusCode() != 200)
        throw new IOException("Non-successful HTTP response: " + status.getReasonPhrase());
9
CodeRank
This code example shows how to use the following methods:addHeader, addHeader
	} 
 
	void addHeaders(HttpPost post) {
		checkState(); 
 
		post.addHeader("Host", "play.google.com");
		post.addHeader("Connection", "keep-alive");
		post.addHeader("Content-Type", "application/json; charset=utf-8");
		// XXX get this dynamically by fetching and executing the nocache.js file:  
		// https://play.google.com/apps/publish/v2/gwt/com.google.wireless.android.vending.developer.fox.Fox.nocache.js 
		post.addHeader("X-GWT-Permutation", "EC203CA4CDFF1F0285B065B554E0D784");
		post.addHeader("Origin", "https://play.google.com");
		post.addHeader("X-GWT-Module-Base", "https://play.google.com/apps/publish/v2/gwt/");
		post.addHeader("Referer", "https://play.google.com/apps/publish/v2/?dev_acc="
				+ getSessionCredentials().getDeveloperAccountId()); 
	} 
 
	String createDeveloperUrl(String baseUrl) {
		checkState(); 
 
8
CodeRank
This code example shows how to use the following methods:setEntity, addHeader
        HttpClient httpclient = new DefaultHttpClient();
        String headerValue = DropboxUtils.getFileExchangeAuthHeader(authToken, authTokenSecret);
         
        // See related encoding change in DropboxDownloadHelper. 
        String url = FILE_UPLOAD_URL + URLEncoder.encode(fileName, "UTF-8").replace("+", "%20");
        HttpPost httppost = new HttpPost(url);
        httppost.addHeader("Authorization", headerValue);
        httppost.setEntity(new FileEntity(new File(filePath), "application/x-sqlite3"));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        if(response.getStatusLine().getStatusCode() == 200 && resEntity != null){
            InputStream is = resEntity.getContent();
            JSONObject jsonResponse = new JSONObject(IOUtils.toString(is));
            if(jsonResponse.getString("modified") != null){
                is.close();
                return true; 
            } 
        } 
        return false; 
    }; 
7
CodeRank
This code example shows how to use the following methods:setEntity, addHeader, getHeaders
	 * @throws IOException Wenn waehrend der Uebertragung ein Fehler auftritt 
	 */ 
	private String executeRequest(String request) throws Exception {
		checkPreferenceChange(); 
		 
		HttpPost httpRequest = new HttpPost(url);
 
		if (jsessionid != null) {
			httpRequest.addHeader("Cookie", "JSESSIONID=" + jsessionid);
			Log.d("Network", "Added header: " + httpRequest.getHeaders("Cookie")[0].toString());
		} 
 
		StringEntity entity = new StringEntity(request, "UTF-8");
		httpRequest.setEntity(entity);
 
		HttpResponse httpResponse = client.execute(httpRequest);
		Log.d("Network", "Sent: " + request);
		 
		ByteArrayOutputStream body = new ByteArrayOutputStream();
		httpResponse.getEntity().writeTo(body);
		String response = body.toString();
7
CodeRank
This code example shows how to use the following methods:addHeader
        Assert.assertTrue(conn.contentDecoder instanceof IdentityDecoder);
    } 
 
    @Test 
    public void testPrepareLengthDelimitedDecoder() throws Exception { 
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(HTTP.CONTENT_LEN, "10");
        response.addHeader(HTTP.CONTENT_TYPE, "stuff");
        response.addHeader(HTTP.CONTENT_ENCODING, "identity");
        Mockito.when(session.channel()).thenReturn(channel);
 
        final HttpEntity entity = conn.prepareDecoder(response);
        Assert.assertNotNull(entity);
        Assert.assertEquals(10, entity.getContentLength());
        Assert.assertFalse(entity.isChunked());
        Assert.assertNotNull(entity.getContentType());
        Assert.assertEquals("stuff", entity.getContentType().getValue());
        Assert.assertNotNull(entity.getContentEncoding());
        Assert.assertEquals("identity", entity.getContentEncoding().getValue());
        Assert.assertTrue(conn.contentDecoder instanceof LengthDelimitedDecoder);
6
CodeRank
This code example shows how to use the following methods:setEntity, addHeader, setHeader
	} 
	 
	 
	public String post(String path, ArrayList <NameValuePair> params) throws Exception {
        String url = buildPostUrl(path);
        HttpPost request = new HttpPost(url);
		request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
		request.addHeader("Content-Type", "application/x-www-form-urlencoded");
		if (getAuthHash() != null) {  
			request.setHeader("Authorization", "Basic "+ getAuthHash()); 
		} 
		if (getConsumer().getToken() != null && getConsumer().getTokenSecret() != null) { 
			getConsumer().sign(request);  //OAuth signing
		} 
		 
		String response = executeRequest(request, url).get(0);
 
		return response;
	} 
	 
6
CodeRank
This code example shows how to use the following methods:addHeader
import org.apache.http.client.methods.HttpGet; 
 
public class UriRead extends UriHttp { 
 
	public UriRead(URI uri) throws HttpException, IOException {
		HttpGet httpGet = new HttpGet(uri.toASCIIString());
		httpGet.addHeader("Connection", "close");
		execute(httpGet);
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:addHeader, removeHeaders
    public static Test suite() {
        return buildTestSuite(HttpCoreUtilsTest.class); 
    } 
 
    public void testHasHeaderListValueExactMatch() { 
        BasicHttpResponse msg = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, 200, ""));
        BasicHeader header1 = new BasicHeader("key", "value1");
        BasicHeader header2 = new BasicHeader("key", "value2");
        msg.addHeader(header1);
        msg.addHeader(header2);
         
        assertTrue(HttpCoreUtils.hasHeaderListValue(msg, "key", "value1"));
        assertTrue(HttpCoreUtils.hasHeaderListValue(msg, "key", "value2"));
        assertFalse(HttpCoreUtils.hasHeaderListValue(msg, "key", "value3"));
        assertFalse(HttpCoreUtils.hasHeaderListValue(msg, "key1", "value1"));
        assertFalse(HttpCoreUtils.hasHeaderListValue(msg, "", ""));
         
        msg.removeHeaders("key");
        assertFalse(HttpCoreUtils.hasHeaderListValue(msg, "key", "value1"));
        assertFalse(HttpCoreUtils.hasHeaderListValue(msg, "key", "value2"));

6
CodeRank
This code example shows how to use the following methods:addHeader
		System.out.println("AlfrescoShareDirectDeployer.reloadWebScripts()");
 
		String alfrescoURL = getGenerationParameters().get(CONFIGURATION_PARAMETER_SHARE_URL);
 
		HttpClient httpclient = new DefaultHttpClient();
		HttpPost post = new HttpPost(alfrescoURL + SERVICE_RESET_ON_SUBMIT_REFRESH_WEB_SCRIPTS);
 
		Credentials defaultcreds = new UsernamePasswordCredentials(getAdminLogin(), getAdminPassWord());
		post.addHeader(new BasicScheme().authenticate(defaultcreds, post));
 
		post.addHeader("Content-Type", FORM_URL_ENCODED_CONTENT_TYPE + "; charset=UTF-8");
		String executeRequest = AlfrescoHotDeployerHelper.executeRequest(httpclient, post);
 
		// search for error 
 
		System.out.println(executeRequest);
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:setEntity, addHeader, setParams
			// Set verifier 
			HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
		} 
         
		// Create HTTP/POST request with a JSON entity containing the request 
		HttpPost request = new HttpPost(serviceUri);
		HttpParams params = new BasicHttpParams();
		HttpConnectionParams.setConnectionTimeout(params, getConnectionTimeout());
		HttpConnectionParams.setSoTimeout(params, getSoTimeout());
		 
		HttpProtocolParams.setVersion(params, PROTOCOL_VERSION);
		request.setParams(params);
		 
		 
		if (sessionId != null)
			request.addHeader("X-GEOREMINDME-SESSION", sessionId);
		 
		HttpEntity entity;
		try 
		{ 

6
CodeRank

Related AbstractHttpMessage addHeader Questions & Answers:

addHeader Method Overview
Adds a header to this message.
See Code Examples for other Android AbstractHttpMessage Methods: