On successful queries (on errors ReadAll runs in CheckResponse), the
Response.Body is not read all the way to the EOF as json.Decoder is used,
which stops at the end of the object, which is probably followed by a \n.
Then, Response.Body.Close() is called. When that happens with a non-drained
Body, the TCP/TLS connection is closed (which makes sense, in case there was
still a lot to read from the network), stopping the Transport from reusing
it. Also, a library user can't drain the Body themselves because Close() is
called before passing the Response to the user.
Since we know GitHub API responses only carry a single JSON object, draining
before closing is free, and saving all those handshakes causes huge savings
in latency, bandwidth and CPU for both the client and the poor GitHub
servers.
Here's the result of running the benchmark below on a ADSL connection:
before: 2m3.001599093s
after: 33.753543928s
func main() {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
gh := github.NewClient(tc)
start := time.Now()
for i := 0; i < 100; i++ {
gh.Repositories.Get("FiloSottile", "gvt")
fmt.Print(".")
}
fmt.Printf("\n%s\n", time.Now().Sub(start))
}
If a redirect to AWS occurs, then the redirect will be canceled and
the redirect Location will be returned in redirectURL and the
io.ReadCloser will be nil. At this point, the user would need to
perform the http.Get with the redirectURL in a different http.Client
(without the GitHub authentication transport).
Note that this is a breaking API change.
Fixes#246.
Change-Id: I4fe2dfc9cd0ce81934a07f11a6296e71c7dd51a0
Check if the default value supplied is a slice and not nil, if so
print the list of values supplied.
Test case for slice argument with and without default values.
Default values for slices was not printed because slice is not
comparable, but the zero value for slices is nil.
In V3 of the GitHub API, pull request comments are created in two ways. The
first way is to create a comment on a specific line of a file in a commit
with the following parameters:
| Name | Type | Description |
|-----------|---------|--------------------------------------------------------|
| body | string | Required. The text of the comment |
| commit_id | string | Required. The SHA of the commit to comment on. |
| path | string | Required. The relative path of the file to comment on. |
| position | integer | Required. The line index in the diff to comment on. |
And the second way is through a reply to an existing comment with the following
parameters:
| Name | Type | Description |
|-------------|---------|---------------------------------------|
| body | string | Required. The text of the comment |
| in_reply_to | integer | Required. The comment id to reply to. |
This commit adds support for the second (or "Alternative Input" according to
the GitHub docs) way.
This commit fixes a bug where if a multiple value argument (slice) has default
values, the submitted values will be appended to the default. Not
overriding them as expected.
Rate is now a method, not a field.
Mention RateLimits rather than RateLimit since the latter is deprecated.
Use Go convention for marking deprecated identifiers. See
257114af91.