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 8394A200AE4 for ; Thu, 9 Jun 2016 11:24:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 828C9160A58; Thu, 9 Jun 2016 09:24:23 +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 CC10D160A5C for ; Thu, 9 Jun 2016 11:24:22 +0200 (CEST) Received: (qmail 62495 invoked by uid 500); 9 Jun 2016 09:24:21 -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 62238 invoked by uid 99); 9 Jun 2016 09:24:21 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 09:24:21 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 900FB2C1F69 for ; Thu, 9 Jun 2016 09:24:21 +0000 (UTC) Date: Thu, 9 Jun 2016 09:24:21 +0000 (UTC) From: "Jean-Eric Cuendet (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HTTPCORE-423) Content-Type is wrongly handled in case of empty body during a PUT MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 09 Jun 2016 09:24:23 -0000 [ https://issues.apache.org/jira/browse/HTTPCORE-423?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jean-Eric Cuendet updated HTTPCORE-423: --------------------------------------- Description: We use Zuul to forward requests. We have a PUT without body, in this case the content-type is null, and content-length = 0 But in the below code, we get the content-type from the request ans handle it badly: {{monospaced}} class org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter method private HttpResponse forward(HttpClient httpclient, String verb, String uri, HttpServletRequest request, MultiValueMap headers, MultiValueMap params, InputStream requestEntity) throws Exception { Map info = this.helper.debug(verb, uri, headers, params, requestEntity); URL host = RequestContext.getCurrentContext().getRouteHost(); HttpHost httpHost = getHttpHost(host); uri = StringUtils.cleanPath((host.getPath() + uri).replaceAll("/{2,}", "/")); HttpRequest httpRequest; int contentLength = request.getContentLength(); {color:red} InputStreamEntity entity = new InputStreamEntity(requestEntity, contentLength, ContentType.create(request.getContentType())); {color:red} {{monospaced}} ContentType.create calls a InputStreamEntity constructor: {{monospaced}} public InputStreamEntity(final InputStream instream, final long length, final ContentType contentType) { super(); this.content = Args.notNull(instream, "Source input stream"); this.length = length; if (contentType != null) { {color:red} setContentType(contentType.toString()); {color:red} } } {{monospaced}} toString() is called on contentType which has a null mimeType member. This is wrong: - Never call toString() in *REAL* code, only for debugging - the method return "null" (not the null value of the pointer but a string of 4 chars containing "null") > Content-Type is wrongly handled in case of empty body during a PUT > ------------------------------------------------------------------ > > Key: HTTPCORE-423 > URL: https://issues.apache.org/jira/browse/HTTPCORE-423 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore > Affects Versions: 4.4.4 > Reporter: Jean-Eric Cuendet > > We use Zuul to forward requests. > We have a PUT without body, in this case the content-type is null, and content-length = 0 > But in the below code, we get the content-type from the request ans handle it badly: > {{monospaced}} > class org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilter > method private HttpResponse forward(HttpClient httpclient, String verb, String uri, > HttpServletRequest request, MultiValueMap headers, > MultiValueMap params, InputStream requestEntity) > throws Exception { > Map info = this.helper.debug(verb, uri, headers, params, > requestEntity); > URL host = RequestContext.getCurrentContext().getRouteHost(); > HttpHost httpHost = getHttpHost(host); > uri = StringUtils.cleanPath((host.getPath() + uri).replaceAll("/{2,}", "/")); > HttpRequest httpRequest; > int contentLength = request.getContentLength(); > {color:red} > InputStreamEntity entity = new InputStreamEntity(requestEntity, contentLength, > ContentType.create(request.getContentType())); > {color:red} > {{monospaced}} > ContentType.create calls a InputStreamEntity constructor: > {{monospaced}} > public InputStreamEntity(final InputStream instream, final long length, final ContentType contentType) { > super(); > this.content = Args.notNull(instream, "Source input stream"); > this.length = length; > if (contentType != null) { > {color:red} > setContentType(contentType.toString()); > {color:red} > } > } > {{monospaced}} > toString() is called on contentType which has a null mimeType member. > This is wrong: > - Never call toString() in *REAL* code, only for debugging > - the method return "null" (not the null value of the pointer but a string of 4 chars containing "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