jira-importer opened a new issue, #1425:
URL: https://github.com/apache/httpcomponents-core/issues/1425

   **[Jean-Eric 
Cuendet](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jecuendet)**
 opened 
**[HTTPCORE-423](https://issues.apache.org/jira/browse/HTTPCORE-423?redirect=false)**
 and commented
   
   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:
   
   ```
   method private HttpResponse forward(HttpClient httpclient, String verb, 
String uri,
                        HttpServletRequest request, MultiValueMap<String, 
String> headers,
                        MultiValueMap<String, String> params, InputStream 
requestEntity)
                                        throws Exception {
                Map<String, Object> 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();
   
                InputStreamEntity entity = new InputStreamEntity(requestEntity, 
contentLength,
                                ContentType.create(request.getContentType()));
   
   ```
   
   ContentType.create() calls a InputStreamEntity constructor:
   
   ```
   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) {
   
               setContentType(contentType.toString());
   
           }
       }
   ```
   
   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")
   
   
   
   ---
   
   **Affects:** 4.4.4, 4.4.5
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to