Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix get the latest release tag error #2374

Merged
merged 1 commit into from
Mar 25, 2020
Merged

fix get the latest release tag error #2374

merged 1 commit into from
Mar 25, 2020

Conversation

kslr
Copy link
Contributor

@kslr kslr commented Mar 25, 2020

@sunshineplan
Copy link
Contributor

sunshineplan commented Mar 25, 2020

https://developer.github.com/v3/#user-agent-required
cURL sends a valid User-Agent header by default. If you provide an invalid User-Agent header via cURL (or via an alternative client), you will receive a 403 Forbidden response:

curl -iH 'User-Agent: ' https://api.github.com/meta
HTTP/1.0 403 Forbidden
Connection: close
Content-Type: text/html
Request forbidden by administrative rules.
Please make sure your request has a User-Agent header.
Check https://developer.github.com for other possible causes.

官方文档的描述,curl会自带默认的User-Agent,所以其实也没必要另外再加个。

@sunshineplan
Copy link
Contributor

https://developer.github.com/v3/#current-version
By default, all requests to https://api.github.com receive the v3 version of the REST API. We encourage you to explicitly request this version via the Accept header.

Accept: application/vnd.github.v3+json

按照推荐使用以下代码测试60次(不进行认证,每个IP每小时只能使用api60次)

#! /bin/bash

for i in {1..60}
do
    curl -si https://api.github.com/repos/v2ray/v2ray-core/releases/latest -H "Accept: application/vnd.github.v3+json" >> test
done

全都能返回正常的json格式,当然使用-H "Accept: application/json"也通过了测试,唯一的区别是在返回头中X-GitHub-Media-Type: github.v3,而不是X-GitHub-Media-Type: github.v3; format=json,这个应该也没太大影响。
根据上面的测试,未发现User-Agent为必须信息(curl自带User-Agent,如curl/7.55.1,并且被Github所接受),所以建议删除伪装该信息。

@kslr
Copy link
Contributor Author

kslr commented May 31, 2020

我记得我更新了,但看起来好像没有,只能等待下一次了

@kslr kslr added the Next label May 31, 2020
@nicholascw nicholascw deleted the kslr-patch-1 branch June 1, 2020 12:41
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Sep 18, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Sep 21, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Oct 2, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Oct 14, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Oct 14, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Oct 14, 2020
IceCodeNew added a commit to IceCodeNew/qbittorrent-nox-static that referenced this pull request Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants