hmil / RosHTTP

Unified Scala.js + Scala HTTP client API
MIT License
126 stars 24 forks source link

Issue35 #36

Closed easel closed 8 years ago

easel commented 8 years ago

No test yet as I can't figure out how to get express to send an empty content-type header.

hmil commented 8 years ago

Wow I must have been very tired when I wrote this charset-related part of the code.

You can test the bug with this code on the server-side:

app.get('/raw_greeting', function(req, res) {
  res.write("Hello world").end(); // Does not send Content-Type header
});

and this test function:

"can omit content-type" - {
  HttpRequest(s"$SERVER_URL/raw_greeting")
    .send()
    .map({
      res => res.body ==> "Hello world"
    })
}

However, you will also need to correct charsetFromContentType method which uses a hardcoded "utf-8" as default instead of the oneByteCharset constant. Currently, the oneByteCharset is only used if we get a header like Content-Type: type/subtype but if we do not get any Content-Type header at all, it will use the hardcoded "utf-8" string...

The test case actually causes a failure on the jvm as well which I will look into.

easel commented 8 years ago

Ahh, cool. I'll see about the fixups on the JS side in a few hours after I sleep. Thanks for the tip.

hmil commented 8 years ago

All right, I cleaned up my mess and fixed the issue in #37 . Thanks for the bug report!