python - Flask and Werkzeug: Testing a post request with custom headers -
i'm testing app suggestions http://flask.pocoo.org/docs/testing/, add header post request.
my request currently:
self.app.post('/v0/scenes/test/foo', data=dict(image=(stringio('fake image'), 'image.png'))) but add content-md5 request. possible?
my investigations:
flask client (in flask/testing.py) extends werkzeug's client, documented here: http://werkzeug.pocoo.org/docs/test/
as can see, post uses open. open has:
parameters: as_tuple – returns tuple in form (environ, result) buffered – set true buffer application run. automatically close application well. follow_redirects – set true if client should follow http redirects. so looks it's not supported. how might such feature working, though?
open take *args , **kwargs used environbuilder arguments. can add headers argument first post request:
with self.app.test_client() client: client.post('/v0/scenes/test/foo', data=dict(image=(stringio('fake image'), 'image.png')), headers={'content-md5': 'some hash'});
Comments
Post a Comment