次のようなバイトストリームがあるとします。
POST / mum / ble?q = huh コンテンツの長さ:18 コンテンツタイプ:application / json; charset = "utf-8" ホスト:localhost:80 ["ドレミ"]
それからWSGIスタイルの「environ」dictを生成する方法はありますか?
うまくいけば、私は簡単な答えを見落としていました、そしてそれは反対の操作と同じくらい簡単に達成できます。検討:
>>> import json
>>> from webob import Request
>>> r = Request.blank('/mum/ble?q=huh')
>>> r.method = 'POST'
>>> r.content_type = 'application/json'
>>> r.charset = 'utf-8'
>>> r.body = json.dumps(['do', 're', 'mi'])
>>> print str(r) # Request's __str__ method gives raw HTTP bytes back!
POST / mum / ble?q = huh コンテンツの長さ:18 コンテンツタイプ:application / json; charset = "utf-8" ホスト:localhost:80 ["ドレミ"]