當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpEntityWrapper類代碼示例

本文整理匯總了Java中org.apache.http.entity.HttpEntityWrapper的典型用法代碼示例。如果您正苦於以下問題:Java HttpEntityWrapper類的具體用法?Java HttpEntityWrapper怎麽用?Java HttpEntityWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HttpEntityWrapper類屬於org.apache.http.entity包,在下文中一共展示了HttpEntityWrapper類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: endEntityViaReflection

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
public static void endEntityViaReflection(HttpEntity entity) {
    if (entity instanceof HttpEntityWrapper) {
        Field f = null;
        try {
            for (Field ff : HttpEntityWrapper.class.getDeclaredFields()) {
                if (ff.getName().equals("wrappedEntity")) {
                    f = ff;
                    break;
                }
            }
            if (f != null) {
                f.setAccessible(true);
                HttpEntity wrapped = (HttpEntity) f.get(entity);
                if (wrapped != null) {
                    wrapped.consumeContent();
                }
            }
        } catch (Throwable t) {
            Log.e(LOG_TAG, "wrappedEntity consume", t);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:AsyncHttpClient.java

示例2: endEntityViaReflection

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
/**
 * This horrible hack is required on Android, due to implementation of BasicManagedEntity, which
 * doesn't chain call consumeContent on underlying wrapped HttpEntity
 *
 * @param entity HttpEntity, may be null
 */
public static void endEntityViaReflection(HttpEntity entity) {
    if (entity instanceof HttpEntityWrapper) {
        try {
            Field f = null;
            Field[] fields = HttpEntityWrapper.class.getDeclaredFields();
            for (Field ff : fields) {
                if (ff.getName().equals("wrappedEntity")) {
                    f = ff;
                    break;
                }
            }
            if (f != null) {
                f.setAccessible(true);
                HttpEntity wrapped = (HttpEntity) f.get(entity);
                if (wrapped != null) {
                    wrapped.consumeContent();
                }
            }
        } catch (Throwable t) {
            Log.e(LOG_TAG, "wrappedEntity consume", t);
        }
    }
}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:30,代碼來源:AsyncHttpClient.java

示例3: endEntityViaReflection

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
/**
 * This horrible hack is required on Android, due to implementation of
 * BasicManagedEntity, which doesn't chain call consumeContent on underlying
 * wrapped HttpEntity
 *
 * @param entity HttpEntity, may be null
 */
public static void endEntityViaReflection(HttpEntity entity) {
    if (entity instanceof HttpEntityWrapper) {
        try {
            Field f = null;
            Field[] fields = HttpEntityWrapper.class.getDeclaredFields();
            for (Field ff : fields) {
                if (ff.getName().equals("wrappedEntity")) {
                    f = ff;
                    break;
                }
            }
            if (f != null) {
                f.setAccessible(true);
                HttpEntity wrapped = (HttpEntity) f.get(entity);
                if (wrapped != null) {
                    wrapped.consumeContent();
                }
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
}
 
開發者ID:hcq0618,項目名稱:AndroidWear-OpenWear,代碼行數:31,代碼來源:AsyncHttpClient.java

示例4: endEntityViaReflection

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
/**
 * This horrible hack is required on Android, due to implementation of BasicManagedEntity, which
 * doesn't chain call consumeContent on underlying wrapped HttpEntity
 *
 * @param httpEntity HttpEntity, may be null
 */
public static void endEntityViaReflection(HttpEntity httpEntity) {
    if (httpEntity instanceof HttpEntityWrapper) {
        try {
            Field f = null;
            Field[] fields = HttpEntityWrapper.class.getDeclaredFields();
            for (Field ff : fields) {
                if (ff.getName().equals("wrappedEntity")) {
                    f = ff;
                    break;
                }
            }
            if (f != null) {
                f.setAccessible(true);
                HttpEntity wrapped = (HttpEntity) f.get(httpEntity);
                if (wrapped != null) {
                    wrapped.consumeContent();
                }
            }
        } catch (Throwable t) {
            Log.e(LOG_TAG, "wrappedEntity consume", t);
        }
    }
}
 
開發者ID:ppdai,項目名稱:BaijiClient4Android,代碼行數:30,代碼來源:AsyncHttpClient.java

示例5: consumeEntityContent

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
/**
 * This horrible hack is required on Android, due to implementation of BasicManagedEntity, which
 * doesn't chain call consumeContent on underlying wrapped HttpEntity
 *
 * @param entity HttpEntity, may be null
 */
public void consumeEntityContent(HttpEntity entity) {
    try {
        // Close the InputStream and release the resources by "consuming the content".
        if (entity instanceof HttpEntityWrapper) {
            Field f = null;
            Field[] fields = HttpEntityWrapper.class.getDeclaredFields();
            for (Field ff : fields) {
                if (ff.getName().equals("wrappedEntity")) {
                    f = ff;
                    break;
                }
            }
            if (f != null) {
                f.setAccessible(true);
                HttpEntity wrapped = (HttpEntity) f.get(entity);
                if (wrapped != null) {
                    wrapped.consumeContent();
                    if (HttpLog.isPrint) {
                        HttpLog.d(TAG, "HttpEntity wrappedEntity reflection consumeContent");
                    }
                }
            }
        } else {
            entity.consumeContent();
        }
    } catch (Throwable t) {
        HttpLog.e(TAG, "wrappedEntity consume error. ", t);
    }
}
 
開發者ID:litesuits,項目名稱:android-lite-http,代碼行數:36,代碼來源:ApacheClient.java

示例6: overrideContentEncoding

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
private void overrideContentEncoding(HttpResponse response) {
	HttpEntity wrapped = new HttpEntityWrapper(response.getEntity()) {
		@Override
		public Header getContentEncoding() {
			return null;
		}
	};

	response.setEntity(wrapped);
}
 
開發者ID:Athou,項目名稱:commafeed,代碼行數:11,代碼來源:ContentEncodingInterceptor.java

示例7: process

import org.apache.http.entity.HttpEntityWrapper; //導入依賴的package包/類
@Override
public void process(HttpResponse response, final HttpContext context)
        throws HttpException, IOException {
    final HttpEntity entity = response.getEntity();

    // Only Json protocol has this header, we only wrap CRC32ChecksumCalculatingInputStream in json protocol clients.
    Header[] headers = response.getHeaders("x-amz-crc32");
    if (entity == null || headers == null || headers.length == 0) {
        return;
    }
    HttpEntity crc32ResponseEntity = new HttpEntityWrapper(entity) {

        private final InputStream content = new CRC32ChecksumCalculatingInputStream(
                wrappedEntity.getContent());

        @Override
        public InputStream getContent() throws IOException {
            return content;
        }

        /**
         * It's important to override writeTo. Some versions of Apache HTTP
         * client use writeTo for {@link org.apache.http.entity.BufferedHttpEntity}
         * and the default implementation just delegates to the wrapped entity
         * which completely bypasses our CRC32 calculating input stream. The
         * {@link org.apache.http.entity.BufferedHttpEntity} is used for the
         * request timeout and client execution timeout features.
         *
         * @see <a href="https://github.com/aws/aws-sdk-java/issues/526">Issue #526</a>
         *
         * @param outstream OutputStream to write contents to
         */
        @Override
        public void writeTo(OutputStream outstream) throws IOException {
            try {
                IOUtils.copy(this.getContent(), outstream);
            } finally {
                this.getContent().close();
            }
        }
    };

    response.setEntity(crc32ResponseEntity);
    context.setAttribute(CRC32ChecksumCalculatingInputStream.class.getName(),
                         crc32ResponseEntity.getContent());
}
 
開發者ID:IBM,項目名稱:ibm-cos-sdk-java,代碼行數:47,代碼來源:CRC32ChecksumResponseInterceptor.java


注:本文中的org.apache.http.entity.HttpEntityWrapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。