Code example for HttpRequestBase

Methods: addHeader

0
			httpRequest = new HttpPost(url);
			((HttpPost) httpRequest).setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
		} 
		 
 
		httpRequest.addHeader("User-Agent", CLIENT_USER_AGENT);
		httpRequest.addHeader("accept", "application/json");
		httpRequest.addHeader("Content-Type", "application/json");
		 
		HttpResponse response = httpclient.execute(httpRequest);
		// Get hold of the response entity 
		HttpEntity entity = response.getEntity();
		 
		// If the response does not enclose an entity, there is no need 
		// to worry about connection release 
		if (entity == null) {
			Log.w(LOGGER_TAG, "entity null? " + url);
			return null; // when is this ever reached? 
		} 
		 
Contextual code suggestions in your IDE  Get Codota for Java