Comments (7)
I added the unquoting code because of trouble with some WSGI frameworks (maybe Django?).
The WSGI spec is really not useful for the issue because it neither dictates that you should unquote paths nor that you shouldn't. Some people think it should be, others don't.
So I copied "real" WSGI servers here: CherryPy, gevent, Tornado, mod_python all unquote.
I believe it's safe to unquote URLs twice (in bjoern and in the framework) -- or can you name some counter-examples?
from bjoern.
I did a test of six WSGI servers to see how they handled this: bjoern, gevent, tornado 1.0.1, tornado 2.0, wsgiref, and gunicorn.
I created a sample app, then curled the following path: /my%20test/34.1%2C-49.7
Of the six servers, only Tornado 1.0.1 left the path urlencoded; the others all printed /my test/34.1,-49.7
, including Tornado 2.0.
Code:
app.py:
def app(environ, start_response):
body = environ['PATH_INFO'] + '\n'
headers = [
('Content-Type', 'text/plain'),
('Content-Length', str(len(body)))
]
start_response('200 OK', headers)
return body
test_bjoern.py
import bjoern
from app import app
bjoern.run(app, '127.0.0.1', 1234)
test_gevent.py
from gevent.wsgi import WSGIServer
from app import app
WSGIServer(('127.0.0.1', 1234), app).serve_forever()
test_tornado.py
from tornado import ioloop, httpserver, wsgi
from app import app
httpserver.HTTPServer(wsgi.WSGIContainer(app)).listen(1234)
ioloop.IOLoop.instance().start()
test_wsgiref.py
from wsgiref import simple_server
from app import app
simple_server.make_server('127.0.0.1', 1234, app).serve_forever()
For gunicorn, I executed the command: gunicorn -w 1 -b 127.0.0.1:1234 app:app
from bjoern.
Interesting; I guess bjoern is doing the right thing then, especially if it matches the behavior of wsgiref
, which is obviously the reference WSGI implementation. That's what I guess for basing my knowledge on Tornado.
Jonas, what do you think about changing the path to be a const char *
. If I understand the matter correctly, making it const means doing one extra memcpy
per request. A memcpy
should be pretty cheap, but on the other hand the only real advantage is silencing a compiler warning -- AFAIK the const violation doesn't actually cause any correctness issues.
from bjoern.
The right way to fix this is use const char*
in the signature and then pass it to unquote_url_inplace
using (char*)path
.
from bjoern.
bump
from bjoern.
minor compiler warning. closing.
from bjoern.
from bjoern.
Related Issues (20)
- unix sockets aren't released on SIGHUP HOT 3
- Bjoern 200-300 rps vs gunicorn 500/600 rps HOT 1
- site don't work
- pip install fails - missing http_parser.h HOT 2
- How to trigger server restart on source file changes? HOT 1
- Build fails on M1 Mac using Homebrew HOT 9
- calling from command line like gunicorn in Profcfile HOT 2
- Build bjoern error in mac m1 with command `pip3 install --global-option=build_ext --global-option="-I/opt/homebrew/include" bjoern` HOT 6
- Production use HOT 1
- Remove flask example HOT 5
- pip install not working on ubuntu 20.04 HOT 5
- Compilation terminated - fatal error: http_parser.h: No such file or directory HOT 1
- Extending to asgi HOT 7
- pip install error HOT 1
- Autostart after changes HOT 1
- broken pipe after running for a while HOT 3
- symbol not found in flat namespace '_ev_cleanup_start'
- pip installation fails (bjoern/request.h:4:10: fatal error: 'ev.h' file not found) HOT 2
- Apple Silicon build not supported. HOT 2
- ev.h not found; command /usr/bin/gcc exit failed with exit code 1 HOT 3
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 bjoern.