'after_request' runs but headers don't get set
See original GitHub issueimport bottle
app = bottle.Bottle()
@app.hook('after_request')
def fn():
print(dict(bottle.response.headers))
bottle.response.headers['abc'] = 'yes'
print(dict(bottle.response.headers))
@app.get('/')
def asdf():
return ''
app.run()
This code runs properly. I’m able to get the headers when I make a request from another program. However if I change the route to
@app.get('/')
def asdf():
bottle.abort(424)
The hook gets run since I can see it in the server process log
Bottle v0.12.13 server starting up (using WSGIRefServer())...
Listening on http://127.0.0.1:8080/
Hit Ctrl-C to quit.
{}
{'abc': 'yes'}
127.0.0.1 - - [15/Jan/2019 21:23:03] "GET / HTTP/1.1" 424 726
but the header is not received in the program which made the call. That program is also quiet simple. curl http://localhost:8080 -D-
I saw #978 and was facing the same problem. Some of the UI frameworks using our APIs break if the error response does not have CORS headers.
Am I doing something wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Go - After request headers are set, request body is empty
Background; NewRequestWithContext set getBody(). You should have that function already defined for your http.NewRequest request.
Read more >axios doesn't see request headers that I set #891 - GitHub
Hi, I tried to make a CORS API post call using axios but I've been never able to do that because I must...
Read more >HTTP | Node.js v19.3.0 Documentation
Sets a single header value for headers object. If this header already exists in the to-be-sent headers, its value will be replaced. Use...
Read more >Using Axios to set request headers - LogRocket Blog
Learn different ways Axios can be used to set request headers for API ... visibility to ensure your users don't run into unknown...
Read more >API — Flask Documentation (2.2.x)
If the import name is not properly set up, that debugging information is lost. ... view_func does not necessarily need to be passed,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s solved in 0.13 but this gets reported quite often for 0.12, so I’ll look into a backport or pull requests fixing this specific issue for 0.12. Let’s keep this issue open for now.
This issue is still valid in latest stable release which is 0.12.16 at the moment of writting this comment.
Particularly fails when working with static_files:
It calls the function but header are not set.