Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F91A200BE7 for ; Mon, 5 Dec 2016 20:39:00 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3E108160B09; Mon, 5 Dec 2016 19:39:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8F220160B18 for ; Mon, 5 Dec 2016 20:38:59 +0100 (CET) Received: (qmail 40628 invoked by uid 500); 5 Dec 2016 19:38:58 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 40607 invoked by uid 99); 5 Dec 2016 19:38:58 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Dec 2016 19:38:58 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7989C2C2A67 for ; Mon, 5 Dec 2016 19:38:58 +0000 (UTC) Date: Mon, 5 Dec 2016 19:38:58 +0000 (UTC) From: "Nhan Thuan Nguyen (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (HTTPCORE-438) Got a java.nio.charset.UnsupportedCharsetException error while the header value consist a charset binary MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 05 Dec 2016 19:39:00 -0000 [ https://issues.apache.org/jira/browse/HTTPCORE-438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15722708#comment-15722708 ] Nhan Thuan Nguyen edited comment on HTTPCORE-438 at 12/5/16 7:38 PM: --------------------------------------------------------------------- Thank you Oleg, new change was tested locally and ran successfully. When will you push to 4.4.6-SNAPSHOT version so that it allows me to pick up this change? was (Author: nhan.thuan.nguyen): Thank you Oleg, what version in the pom.xml should I use? Would 4.4.6-SNAPSHOT version allow me to pick up this change? > Got a java.nio.charset.UnsupportedCharsetException error while the header value consist a charset binary > -------------------------------------------------------------------------------------------------------- > > Key: HTTPCORE-438 > URL: https://issues.apache.org/jira/browse/HTTPCORE-438 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore > Affects Versions: 4.4.5 > Reporter: Nhan Thuan Nguyen > > Got a java.nio.charset.UnsupportedCharsetException error while the header value consist a charset binary (see below). Since the method in org.apache.http.entity.ContentType.get() is hard coded boolean value true for strict param, the method in org.apache.http.entity.ContentType.create() throw the UnsupportedCharsetException. > Can strict param be pass in from a system property, -Dorg.apache.http.entity.contenttype.strict=false? If not set, then set it to true as default. > Content-Type: image/jpeg; charset=binary; name="image_42Colk06m1oO0xfC" > Caused by: java.nio.charset.UnsupportedCharsetException: binary > at java.nio.charset.Charset.forName(Charset.java:531) > at org.apache.http.entity.ContentType.create(ContentType.java:224) > at org.apache.http.entity.ContentType.create(ContentType.java:214) > at org.apache.http.entity.ContentType.get(ContentType.java:299) > at org.apache.http.entity.ContentType.getOrDefault(ContentType.java:346) > at org.apache.http.nio.protocol.AbstractAsyncResponseConsumer.responseReceived(AbstractAsyncResponseConsumer.java:130) > at org.apache.http.impl.nio.client.MainClientExec.responseReceived(MainClientExec.java:315) > at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseReceived(DefaultClientExchangeHandlerImpl.java:147) > at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.responseReceived(HttpAsyncRequestExecutor.java:303) > at org.apache.http.impl.nio.client.InternalRequestExecutor.responseReceived(InternalRequestExecutor.java:108) > at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:255) > at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81) > at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39) > at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:121) > at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162) > at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337) > at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315) > at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276) > at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104) > at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588) > public static ContentType get( > final HttpEntity entity) throws ParseException, UnsupportedCharsetException { > if (entity == null) { > return null; > } > final Header header = entity.getContentType(); > if (header != null) { > final HeaderElement[] elements = header.getElements(); > if (elements.length > 0) { > return create(elements[0], true); > } > } > return null; > } > private static ContentType create(final String mimeType, final NameValuePair[] params, final boolean strict) { > Charset charset = null; > for (final NameValuePair param: params) { > if (param.getName().equalsIgnoreCase("charset")) { > final String s = param.getValue(); > if (!TextUtils.isBlank(s)) { > try { > charset = Charset.forName(s); > } catch (final UnsupportedCharsetException ex) { > if (strict) { > throw ex; > } > } > } > break; > } > } > return new ContentType(mimeType, charset, params != null && params.length > 0 ? params : null); > } -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org