Code example for HttpRequest

Methods: addHeader, containsHeader

0
	/** 
	 * HTTP request interceptor to allow for GZip-encoded data transfer 
	 */ 
	public static HttpRequestInterceptor gzipRequestInterceptor = new HttpRequestInterceptor() {
		public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { 
			if (!request.containsHeader("Accept-Encoding")) { 
				request.addHeader("Accept-Encoding", "gzip"); 
			} 
		} 
	}; 
 
	/** 
	 * HTTP response interceptor that decodes GZipped data 
	 */ 
	public static HttpResponseInterceptor gzipResponseInterceptor = new HttpResponseInterceptor() {
		public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException { 
			HttpEntity entity = response.getEntity(); 
			Header ceheader = entity.getContentEncoding(); 
			if (ceheader != null) { 
				HeaderElement[] codecs = ceheader.getElements(); 
				for (int i = 0; i < codecs.length; i++) {