デフォルトでリクエストがrequests.util
のrequote_uri(uri)
機能を使用して、予約されていない文字を取り消すことができますので、これを動作させるにはPrepared Requestsを使用できます。あなたは既に解析され、URLを自分で準備されている場合は、次の操作を行うとurl
フィールド上書きすることができます:
from requests import Session, Request
s = Session()
req = Request('GET', 'http://localhost:8008?name=kevin%2Eemckinsey')
# This will use `requote_uri` to unquote unreserved characters so %2E becomes a `.`
prepped = req.prepare()
# Forcing the `url` field to be a URL we specified.
prepped.url = 'http://localhost:8008?name=kevin%2Emckinsey'
resp = s.send(prepped)
print(resp.url)
print(resp.json())
# http://localhost:8008?name=kevin%2Emckinsey
# PHP's $_SERVER['REQUEST_URI'] returns:
# {'name': '/?name=kevin%2Emckinsey'}
をこれは私に汚いトリックのように思えるが、私の知る限り、UNQUOTEしないように要求を伝える方法はありません特定の文字。
ありがとうございます!それは確かに問題を回避しました。 –