3

Using just the Flask server with Python, the following get request works:

from flask import Flask, request
app = Flask(__name__)

class Result(Resource):
  def get(self):
    image_id = request.headers.get('image_id')

api.add_resource(Result, '/results')

if __name__ == '__main__':
  app.run(host='0.0.0.0', port=int(os.getenv('PORT', 5000)))

However, using Waitress, the following does not work (image_id is None):

from waitress import serve
from flask import Flask, request
app = Flask(__name__)

class Result(Resource):
  def get(self):
    image_id = request.headers.get('image_id')

api.add_resource(Result, '/results')

if __name__ == '__main__':
  serve(app, host="0.0.0.0", port=int(os.getenv('PORT', 5000)))

POST and other GET requests work fine, it's just GET with headers that doesn't work. Anyone have any ideas?

lepton
  • 715
  • 1
  • 6
  • 22

1 Answers1

2

I had the same issue, after searching around I found this issue on GitHub. Apparently it is a security feature and you should not use _ in your header. So you should rename your header to image-id or something else without a _ character for it to work.

TmKVU
  • 2,910
  • 2
  • 16
  • 30