Comments (3)
mochiweb does not use "unicode strings" anywhere, even though it is using lists of integers they are treated as lists of bytes (more like iolist() than string()). At the time mochiweb was written, Erlang binaries were a lot slower, and they were not supported in HTTP header decoding.
You probably shouldn't fork the code and it can't be fixed without drastically changing the APIs, which isn't something that makes sense at this point. If you want a cleaner all-binary API you'll want to switch web servers. A "fixed" mochiweb (regardless of whether unicode strings or binaries are used) wouldn't be compatible with webmachine either.
from mochiweb.
I found a google group posting from a couple of years back where it was explained.
I realize that there is a history there, and, now, that this behavior is intentional.
However, there is also confusion. Take webmachine, for instance. Webmachine utilizes parse_qs directly to instantiate the url query field in the request object it creates. It then specifies in several places that the keys and values of the proplist that results from parse_qs are "strings". Well, if you decide not to use your own knowledge of what a Erlang string is, since that would be too sensible or you have hit a bug, you might instead look up the webmachine definition (nonstandard by their own admission):
"a list() with all elements in the ASCII range".
Really? Is that 7 bit standard ASCII or US-ASCII? Or 8 bit "extended" ASCII?
Of course, nobody is telling me that I need to treat these as strings, so I can use than as lists of bytes.
from mochiweb.
At the time mochiweb was written, Erlang didn't even support Unicode except for a few functions hidden away in xmerl. Strings were either latin1 or bytes of some other kind, and since these are largely compatible no real distinction was made. The documentation you've found that says ASCII is simply wrong.
from mochiweb.
Related Issues (20)
- Any plans for boolean attribute support? HOT 3
- mochijson:decode() doesn't handle surrogate pairs correctly HOT 5
- build failing on OTP 21 HOT 3
- automate the distribution release HOT 12
- badarg error when I visit my server HOT 6
- Strict-SSL HOT 5
- Warning On OTP 21.2 HOT 5
- Duplicated modules HOT 1
- Example https_store with erlang 21.2.4 failed cause tuple_call HOT 1
- ssl issue, how to fix? HOT 1
- Documentation for setting up the project HOT 1
- To get started HOT 1
- Contributing Doc and Issue flags
- about https HOT 1
- Latest release (v2.21.0, OTP 23/24 compat) not available on hex.pm? HOT 26
- why mochiweb_util:quote_plus/1 function encode \s to + while other encode %20
- error crypto:crypto_one_time cypher not supported HOT 2
- Remove Whitspaces in header values HOT 2
- mochiweb seems to be incompatible with otp 25 HOT 2
- Message Queue will grow when KeepAlive HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mochiweb.