ocsbilisim / rest-client

Automatically exported from code.google.com/p/rest-client
Apache License 2.0
0 stars 0 forks source link

Custom Content-Type gets overwritten #188

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set Content-Type=x-whatever
2. Set method to POST
3. Put stuff in the body
4. Hit green arrow

What is the expected output? What do you see instead?
Expected output is Content-Type: x-whatever
Actual output is Content-Type: text/plain; charset=UTF-8

What version of the product are you using? On what operating system?
1.0.3, Windows 7

Please provide any additional information below.
Traced the sources
Lines 86-89 HTTPHandler.java state:
if ( reqBodyEntity != null ) {
            reqHeaders.put("Content-Length", "" + reqBodyEntity.getContentLength());
            reqHeaders.put("Content-Type", reqBodyEntity.getContentType().getValue());
        }

Content-Length is understandable. Maybe check if Content-Type is already a 
member of reqHeaders before overwriting?

if ( reqBodyEntity != null ) {
  reqHeaders.put("Content-Length", "" + reqBodyEntity.getContentLength());
  if reqHeaders.get("Content-Type") == null {
    reqHeaders.put("Content-Type", reqBodyEntity.getContentType().getValue());
  }
}

Regards,

Wilbert

Original issue reported on code.google.com by Wilbert....@gmail.com on 30 Oct 2013 at 9:48

GoogleCodeExporter commented 9 years ago
Wilbert, thanks for reporting the issue in such detail.

I am marking this issue as Won't Fix for following reasons:

1. Body Content Type needs to be entered in the Body tab.
2. If there is a conflict between the Content-type entered in Header tab and 
Body tab, it seems natural that Body tab needs to get the preference over 
Header.
3. If I change the behavior in (2), it will be a big surprise to the existing 
users.

Original comment by subwiz on 31 Oct 2013 at 6:44