在 Postman 中使用相同的 cookie 和 headers 请求,就像在浏览器中一样 returns 401,但在浏览器中一切正常
Request in Postman with same cookies and headers like in browser returns 401, but in browser all works fine
我试图从这个 url 中抓取数据:
https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11
在网络浏览器中,如果我首先访问主页 https://rgis.mosreg.ru(获取 cookie),然后 - 转到此 url - 一切正常。
但是当我尝试在 Postman 中执行此请求时 - 出现 401“Unautorized”错误。
在 Postman 中,我使用所有相同的 headers 和 cookie,就像在 web-browser 中一样,但它没有帮助。
所有 cookie 和 headers 都使用 Postman INTERCEPTOR
与浏览器同步
我错过了什么?
Chrome screen with headers
Postman screen. Header "mojo" looks line auth header
服务器似乎只接受 HTTP/2 并拒绝 HTTP/1.1 调用。如果你有curl
compiled with http2 support,你可以直接测试这个:
curl --http2 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
输出
< HTTP/2.0 200
< server:nginx/1.19.5 (MOGT Edition @ rgis-pub-app-01)
否则就是returns401
目前,您无法在 Postman 中 运行 此请求,因为 Postman doesn't have http2 support yet
您还可以使用 httpx 包 (pip install httpx[http2]
) python 对其进行测试:
import httpx
import asyncio
url = 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
r = httpx.get(url)
print(r.http_version)
print(r.status_code)
client = httpx.AsyncClient(http2=True)
async def get():
response = await client.get(url)
print(response.http_version)
print(response.status_code)
asyncio.run(get())
输出
HTTP/1.1
401
HTTP/2
200
我试图从这个 url 中抓取数据: https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11
在网络浏览器中,如果我首先访问主页 https://rgis.mosreg.ru(获取 cookie),然后 - 转到此 url - 一切正常。
但是当我尝试在 Postman 中执行此请求时 - 出现 401“Unautorized”错误。 在 Postman 中,我使用所有相同的 headers 和 cookie,就像在 web-browser 中一样,但它没有帮助。 所有 cookie 和 headers 都使用 Postman INTERCEPTOR
与浏览器同步我错过了什么?
Chrome screen with headers Postman screen. Header "mojo" looks line auth header
服务器似乎只接受 HTTP/2 并拒绝 HTTP/1.1 调用。如果你有curl
compiled with http2 support,你可以直接测试这个:
curl --http2 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
输出
< HTTP/2.0 200
< server:nginx/1.19.5 (MOGT Edition @ rgis-pub-app-01)
否则就是returns401
目前,您无法在 Postman 中 运行 此请求,因为 Postman doesn't have http2 support yet
您还可以使用 httpx 包 (pip install httpx[http2]
) python 对其进行测试:
import httpx
import asyncio
url = 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
r = httpx.get(url)
print(r.http_version)
print(r.status_code)
client = httpx.AsyncClient(http2=True)
async def get():
response = await client.get(url)
print(response.http_version)
print(response.status_code)
asyncio.run(get())
输出
HTTP/1.1
401
HTTP/2
200