I have an API url:
When I try to make a GET
request to it, the response is 302 Moved Temporarily
.
My request is:
std::string write_buf = "GET /lol/summoner/v3/summoners/by-name/NikolayDark16?api_key=RGAPI-b2971736-9178-4559-a0d9-7d166093865c HTTP/1.1\r\n"
"Host: www.riotgames.com\r\n"
"Connection: close\r\n"
"\r\n";
If I use Host www.ru.api.riotgames.com
instead, the response is 400 bad request
.
A 302 response is a redirect to another URL. Simply resend the same request to the URL specified in the response's Location
header.
As for the 400 response, the correct hostname to specify in the request's Host
header is ru.api.riotgames.com
(no www.
in front). And don't forget the :
after Host
.
std::string write_buf = "GET /lol/summoner/v3/summoners/by-name/NikolayDark16?api_key=RGAPI-b2971736-9178-4559-a0d9-7d166093865c HTTP/1.1\r\n"
"Host: ru.api.riotgames.com\r\n"
"Connection: close\r\n"
"\r\n";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.