1
0
mirror of synced 2025-12-22 11:26:57 -05:00

Updates REST API examples to HTTP/2 (#6002)

This commit is contained in:
Lucas Alves
2021-05-06 18:30:50 -03:00
committed by GitHub
parent ef77a33633
commit df1ae6420c
10 changed files with 38 additions and 38 deletions

View File

@@ -29,7 +29,7 @@ Check headers to see what OAuth scopes you have, and what the API action accepts
```shell
$ curl -H "Authorization: token OAUTH-TOKEN" {% data variables.product.api_url_pre %}/users/codertocat -I
HTTP/1.1 200 OK
HTTP/2 200
X-OAuth-Scopes: repo, user
X-Accepted-OAuth-Scopes: user
```

View File

@@ -371,10 +371,10 @@ After you click **Install**, look at the output in your Terminal. You should see
```shell
> D, [2018-06-29T15:45:43.773077 #30488] DEBUG -- : ---- received event integration_installation
> D, [2018-06-29T15:45:43.773141 #30488] DEBUG -- : ---- action created
> 192.30.252.44 - - [29/Jun/2018:15:45:43 -0400] "POST / HTTP/1.1" 200 2 0.0067
> 192.30.252.44 - - [29/Jun/2018:15:45:43 -0400] "POST / HTTP/2" 200 2 0.0067
> D, [2018-06-29T15:45:43.833016 #30488] DEBUG -- : ---- received event installation
> D, [2018-06-29T15:45:43.833062 #30488] DEBUG -- : ---- action created
> 192.30.252.39 - - [29/Jun/2018:15:45:43 -0400] "POST / HTTP/1.1" 200 2 0.0019
> 192.30.252.39 - - [29/Jun/2018:15:45:43 -0400] "POST / HTTP/2" 200 2 0.0019
```
This is good news! It means your app received a notification that it was installed on your GitHub account. If you see something like this, your app is running on the server as expected. 🙌

View File

@@ -59,7 +59,7 @@ Create a public, internet accessible HTTP endpoint at the URL you provided to us
##### Example POST sent to your endpoint
```http
POST / HTTP/1.1
POST / HTTP/2
Host: HOST
Accept: */*
Content-Type: application/json
@@ -99,7 +99,7 @@ The code snippets assume you've set an environment variable called `GITHUB_PRODU
**Sample message sent to verify endpoint**
```http
POST / HTTP/2
Host: HOST
Host: HOST
Accept: */*
content-type: application/json
GITHUB-PUBLIC-KEY-IDENTIFIER: 90a421169f0a406205f1563a953312f0be898d3c7b6c06b681aa86a874555f4a

View File

@@ -45,7 +45,7 @@ The event objects returned from the Events API endpoints have the same structure
This example shows the format of the [WatchEvent](#watchevent) response when using the [Events API](/rest/reference/activity#events).
```
HTTP/1.1 200 OK
HTTP/2 200
Link: <https://api.github.com/resource?page=2>; rel="next",
<https://api.github.com/resource?page=5>; rel="last"
```

View File

@@ -61,7 +61,7 @@ Also, the `User-Agent` for the requests will have the prefix `GitHub-Hookshot/`.
#### Example delivery
```shell
> POST /payload HTTP/1.1
> POST /payload HTTP/2
> Host: localhost:4567
> X-GitHub-Delivery: 72d3162e-cc78-11e3-81ab-4c9367dc0958{% if enterpriseServerVersions contains currentVersion or currentVersion == "github-ae@latest" %}

View File

@@ -37,7 +37,7 @@ If an image is showing up in your browser but not on {% data variables.product.p
2. Request the image headers using `curl`.
```shell
$ curl -I https://www.my-server.com/images/some-image.png
> HTTP/1.1 200 OK
> HTTP/2 200
> Date: Fri, 06 Jun 2014 07:27:43 GMT
> Expires: Sun, 06 Jul 2014 07:27:43 GMT
> Content-Type: image/x-png
@@ -60,7 +60,7 @@ If you changed an image recently and it's showing up in your browser but not {%
2. Request the image headers using `curl`.
```shell
$ curl -I https://www.my-server.com/images/some-image.png
> HTTP/1.1 200 OK
> HTTP/2 200
> Expires: Fri, 01 Jan 1984 00:00:00 GMT
> Content-Type: image/png
> Content-Length: 2339

View File

@@ -58,7 +58,7 @@ Mmmmm, tastes like [JSON][json]. Let's add the `-i` flag to include headers:
```shell
$ curl -i https://api.github.com/users/defunkt
> HTTP/1.1 200 OK
> HTTP/2 200
> Server: GitHub.com
> Date: Sun, 11 Nov 2012 18:43:28 GMT
> Content-Type: application/json; charset=utf-8
@@ -261,7 +261,7 @@ Next, let's fetch our newly created repository:
```shell
$ curl -i {% data variables.product.api_url_pre %}/repos/pengwynn/blog
> HTTP/1.1 404 Not Found
> HTTP/2 404
> {
> "message": "Not Found"
@@ -312,7 +312,7 @@ time taking note of the response headers:
```shell
$ curl -i {% data variables.product.api_url_pre %}/repos/rails/rails/issues
> HTTP/1.1 200 OK
> HTTP/2 200
> ...
> Link: &lt;{% data variables.product.api_url_pre %}/repositories/8514/issues?page=2&gt;; rel="next", &lt;{% data variables.product.api_url_pre %}/repositories/8514/issues?page=30&gt;; rel="last"
@@ -343,7 +343,7 @@ $ "labels": ["design"] \
$ }' \
$ {% data variables.product.api_url_pre %}/repos/pengwynn/api-sandbox/issues
> HTTP/1.1 201 Created
> HTTP/2 201
> Location: {% data variables.product.api_url_pre %}/repos/pengwynn/api-sandbox/issues/17
> X-RateLimit-Limit: 5000
@@ -396,7 +396,7 @@ first call we made to get defunkt's profile:
```shell
$ curl -i {% data variables.product.api_url_pre %}/users/defunkt
> HTTP/1.1 200 OK
> HTTP/2 200
> ETag: "bfd85cbf23ac0b0c8a29bee02e7117c6"
```
@@ -409,7 +409,7 @@ we can tell the API to give us the resource again, only if it has changed:
$ curl -i -H 'If-None-Match: "bfd85cbf23ac0b0c8a29bee02e7117c6"' \
$ {% data variables.product.api_url_pre %}/users/defunkt
> HTTP/1.1 304 Not Modified
> HTTP/2 304
```
The `304` status indicates that the resource hasn't changed since the last time

View File

@@ -53,17 +53,17 @@ for the `X-GitHub-Media-Type` header:
```shell
$ curl {% data variables.product.api_url_pre %}/users/technoweenie -I
> HTTP/1.1 200 OK
> HTTP/2 200
> X-GitHub-Media-Type: github.v3
$ curl {% data variables.product.api_url_pre %}/users/technoweenie -I \
$ -H "Accept: application/vnd.github.full+json"
> HTTP/1.1 200 OK
> HTTP/2 200
> X-GitHub-Media-Type: github.v3; param=full; format=json
$ curl {% data variables.product.api_url_pre %}/users/technoweenie -I \
$ -H "Accept: application/vnd.github.v3.full+json"
> HTTP/1.1 200 OK
> HTTP/2 200
> X-GitHub-Media-Type: github.v3; param=full; format=json
```

View File

@@ -35,7 +35,7 @@ sent and received as JSON.
```shell
$ curl -I {% data variables.product.api_url_pre %}/users/octocat/orgs
> HTTP/1.1 200 OK
> HTTP/2 200
> Server: nginx
> Date: Fri, 12 Oct 2012 23:33:14 GMT
> Content-Type: application/json; charset=utf-8
@@ -139,7 +139,7 @@ Authenticating with invalid credentials will return `401 Unauthorized`:
```shell
$ curl -I {% data variables.product.api_url_pre %} -u foo:bar
> HTTP/1.1 401 Unauthorized
> HTTP/2 401
> {
> "message": "Bad credentials",
@@ -154,7 +154,7 @@ the API will temporarily reject all authentication attempts for that user
```shell
$ curl -i {% data variables.product.api_url_pre %} -u {% if currentVersion == "free-pro-team@latest" or currentVersion == "github-ae@latest" %}
-u <em>valid_username</em>:<em>valid_token</em> {% endif %}{% if enterpriseServerVersions contains currentVersion %}-u <em>valid_username</em>:<em>valid_password</em> {% endif %}
> HTTP/1.1 403 Forbidden
> HTTP/2 403
> {
> "message": "Maximum number of login attempts exceeded. Please try again later.",
> "documentation_url": "{% data variables.product.doc_url_pre %}"
@@ -202,7 +202,7 @@ receive request bodies:
1. Sending invalid JSON will result in a `400 Bad Request` response.
HTTP/1.1 400 Bad Request
HTTP/2 400
Content-Length: 35
{"message":"Problems parsing JSON"}
@@ -210,7 +210,7 @@ receive request bodies:
2. Sending the wrong type of JSON values will result in a `400 Bad
Request` response.
HTTP/1.1 400 Bad Request
HTTP/2 400
Content-Length: 40
{"message":"Body should be a JSON object"}
@@ -218,7 +218,7 @@ receive request bodies:
3. Sending invalid fields will result in a `422 Unprocessable Entity`
response.
HTTP/1.1 422 Unprocessable Entity
HTTP/2 422
Content-Length: 149
{
@@ -373,7 +373,7 @@ The returned HTTP headers of any API request show your current rate limit status
```shell
$ curl -I {% data variables.product.api_url_pre %}/users/octocat
> HTTP/1.1 200 OK
> HTTP/2 200
> Date: Mon, 01 Jul 2013 17:27:06 GMT
> X-RateLimit-Limit: 60
> X-RateLimit-Remaining: 56
@@ -396,7 +396,7 @@ new Date(1372700873 * 1000)
If you exceed the rate limit, an error response returns:
```shell
> HTTP/1.1 403 Forbidden
> HTTP/2 403
> Date: Tue, 20 Aug 2013 14:50:41 GMT
> X-RateLimit-Limit: 60
> X-RateLimit-Remaining: 0
@@ -416,7 +416,7 @@ If your OAuth application needs to make unauthenticated calls with a higher rate
```shell
$ curl -u my_client_id:my_client_secret {% data variables.product.api_url_pre %}/user/repos
> HTTP/1.1 200 OK
> HTTP/2 200
> Date: Mon, 01 Jul 2013 17:27:06 GMT
> X-RateLimit-Limit: 5000
> X-RateLimit-Remaining: 4966
@@ -442,7 +442,7 @@ Abuse rate limits are not intended to interfere with legitimate use of the API.
If your application triggers this rate limit, you'll receive an informative response:
```shell
> HTTP/1.1 403 Forbidden
> HTTP/2 403
> Content-Type: application/json; charset=utf-8
> Connection: close
@@ -502,7 +502,7 @@ whenever possible.
```shell
$ curl -I {% data variables.product.api_url_pre %}/user
> HTTP/1.1 200 OK
> HTTP/2 200
> Cache-Control: private, max-age=60
> ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
> Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
@@ -512,7 +512,7 @@ $ curl -I {% data variables.product.api_url_pre %}/user
> X-RateLimit-Reset: 1372700873
$ curl -I {% data variables.product.api_url_pre %}/user -H 'If-None-Match: "644b5b0155e6404a9cc4bd9d8b1ae730"'
> HTTP/1.1 304 Not Modified
> HTTP/2 304
> Cache-Control: private, max-age=60
> ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
> Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
@@ -522,7 +522,7 @@ $ curl -I {% data variables.product.api_url_pre %}/user -H 'If-None-Match: "644b
> X-RateLimit-Reset: 1372700873
$ curl -I {% data variables.product.api_url_pre %}/user -H "If-Modified-Since: Thu, 05 Jul 2012 15:31:30 GMT"
> HTTP/1.1 304 Not Modified
> HTTP/2 304
> Cache-Control: private, max-age=60
> Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
> Vary: Accept, Authorization, Cookie
@@ -544,7 +544,7 @@ Here's a sample request sent from a browser hitting
```shell
$ curl -I {% data variables.product.api_url_pre %} -H "Origin: http://example.com"
HTTP/1.1 302 Found
HTTP/2 302
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
```
@@ -553,7 +553,7 @@ This is what the CORS preflight request looks like:
```shell
$ curl -I {% data variables.product.api_url_pre %} -H "Origin: http://example.com" -X OPTIONS
HTTP/1.1 204 No Content
HTTP/2 204
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-GitHub-OTP, X-Requested-With
Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE

View File

@@ -24,14 +24,14 @@ Events are optimized for polling with the "ETag" header. If no new events have b
``` shell
$ curl -I {% data variables.product.api_url_pre %}/users/tater/events
> HTTP/1.1 200 OK
> HTTP/2 200
> X-Poll-Interval: 60
> ETag: "a18c3bded88eb5dbb5c849a489412bf3"
# The quotes around the ETag value are important
$ curl -I {% data variables.product.api_url_pre %}/users/tater/events \
$ -H 'If-None-Match: "a18c3bded88eb5dbb5c849a489412bf3"'
> HTTP/1.1 304 Not Modified
> HTTP/2 304
> X-Poll-Interval: 60
```
@@ -56,7 +56,7 @@ To get a feed in Atom format, you must specify the `application/atom+xml` type i
#### Response
```shell
HTTP/1.1 200 OK
HTTP/2 200
```
```xml
@@ -122,14 +122,14 @@ Notifications are optimized for polling with the `Last-Modified` header. If the
``` shell
# Add authentication to your requests
$ curl -I {% data variables.product.api_url_pre %}/notifications
HTTP/1.1 200 OK
HTTP/2 200
Last-Modified: Thu, 25 Oct 2012 15:16:27 GMT
X-Poll-Interval: 60
# Pass the Last-Modified header exactly
$ curl -I {% data variables.product.api_url_pre %}/notifications
$ -H "If-Modified-Since: Thu, 25 Oct 2012 15:16:27 GMT"
> HTTP/1.1 304 Not Modified
> HTTP/2 304
> X-Poll-Interval: 60
```