HTTP and character encodings

Ganesh Sittampalam ganesh at
Tue Sep 11 19:38:09 CEST 2012

On 11/09/2012 09:30, Christian Maeder wrote:
> Am 11.09.2012 00:22, schrieb Ganesh Sittampalam:
>> Hi,
>> tl;dr: I'd like to remove the String instances from the HTTP package.
>> The HTTP library is overloaded on the type for request and response
>> bodies; there are instances for String and both strict and lazy
>> Bytestrings.
>> Unfortunately, the String instance is rather broken. A String ought to
>> represent Unicode data, but the HTTP wire format is bytes, and HTTP
>> makes no attempt to handle encoding.
> if you remove the String instance I would need to encode my strings
> manually (and maybe worse than it is done now).

The obvious way to encode them is to use ByteString.Char8.pack which is
exactly what HTTP does now. I can't really think of anything worse that
someone might do by accident.

> Which alternative (better maintained) packages could I use if I have to
> change my code anyway?

There's http-conduit, which also doesn't support String, but does
support https and has a much cleaner interface. If conduit ever made it
into the Platform then it would be an obvious choice to replace HTTP;
but I still have some faith in lazy IO which is one of the reasons why I
put effort into the HTTP package.



More information about the Libraries mailing list