Skip to content

Commit

Permalink
style: reformat all go files
Browse files Browse the repository at this point in the history
activate go linter
  • Loading branch information
developStorm committed May 22, 2024
1 parent 990c9c3 commit a97b459
Show file tree
Hide file tree
Showing 79 changed files with 5,077 additions and 5,034 deletions.
1 change: 0 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
go-fmt:
name: Go Formatter
runs-on: ubuntu-latest
if: false # Pending activation
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand Down
6 changes: 3 additions & 3 deletions conn_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func _write(writer io.Writer, data []byte) error {

// Run the configured server. As soon as it returns, it is listening.
// Returns a channel that receives a timeoutTestError on error, or is closed on successful completion.
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) (chan *timeoutTestError) {
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) chan *timeoutTestError {
errorChan := make(chan *timeoutTestError)
if cfg.endpoint != "" {
// Only listen on localhost
Expand Down Expand Up @@ -307,7 +307,7 @@ var connTestConfigs = []connTimeoutTestConfig{
serverToClientPayload: []byte("abc"),
clientToServerPayload: []byte("defghi"),

failStep: testStepConnect,
failStep: testStepConnect,
failError: "i/o timeout",
},
// short session timeout, medium connect timeout, with connect to nonexistent endpoint.
Expand All @@ -326,7 +326,7 @@ var connTestConfigs = []connTimeoutTestConfig{
serverToClientPayload: []byte("abc"),
clientToServerPayload: []byte("defghi"),

failStep: testStepConnect,
failStep: testStepConnect,
failError: "i/o timeout",
},
// Get an IO timeout on the read.
Expand Down
9 changes: 5 additions & 4 deletions lib/http/chunked.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ func isASCIISpace(b byte) bool {

// removeChunkExtension removes any chunk-extension from p.
// For example,
// "0" => "0"
// "0;token" => "0"
// "0;token=val" => "0"
// `0;token="quoted string"` => "0"
//
// "0" => "0"
// "0;token" => "0"
// "0;token=val" => "0"
// `0;token="quoted string"` => "0"
func removeChunkExtension(p []byte) ([]byte, error) {
semi := bytes.IndexByte(p, ';')
if semi == -1 {
Expand Down
75 changes: 37 additions & 38 deletions lib/http/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@ import (
// When following redirects, the Client will forward all headers set on the
// initial Request except:
//
// * when forwarding sensitive headers like "Authorization",
// "WWW-Authenticate", and "Cookie" to untrusted targets.
// These headers will be ignored when following a redirect to a domain
// that is not a subdomain match or exact match of the initial domain.
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
// will forward the sensitive headers, but a redirect to "bar.com" will not.
//
// * when forwarding the "Cookie" header with a non-nil cookie Jar.
// Since each redirect may mutate the state of the cookie jar,
// a redirect may possibly alter a cookie set in the initial request.
// When forwarding the "Cookie" header, any mutated cookies will be omitted,
// with the expectation that the Jar will insert those mutated cookies
// with the updated values (assuming the origin matches).
// If Jar is nil, the initial cookies are forwarded without change.
//
// - when forwarding sensitive headers like "Authorization",
// "WWW-Authenticate", and "Cookie" to untrusted targets.
// These headers will be ignored when following a redirect to a domain
// that is not a subdomain match or exact match of the initial domain.
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
// will forward the sensitive headers, but a redirect to "bar.com" will not.
//
// - when forwarding the "Cookie" header with a non-nil cookie Jar.
// Since each redirect may mutate the state of the cookie jar,
// a redirect may possibly alter a cookie set in the initial request.
// When forwarding the "Cookie" header, any mutated cookies will be omitted,
// with the expectation that the Jar will insert those mutated cookies
// with the updated values (assuming the origin matches).
// If Jar is nil, the initial cookies are forwarded without change.
type Client struct {
// Transport specifies the mechanism by which individual
// HTTP requests are made.
Expand Down Expand Up @@ -344,11 +343,11 @@ func basicAuth(username, password string) string {
// the following redirect codes, Get follows the redirect, up to a
// maximum of 10 redirects:
//
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
//
// An error is returned if there were too many redirects or if there
// was an HTTP protocol error. A non-2xx response doesn't cause an
Expand All @@ -373,11 +372,11 @@ func (c *Client) Get(url string) (r *Response, err error) {
// following redirect codes, Get follows the redirect after calling the
// Client's CheckRedirect function:
//
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
//
// An error is returned if the Client's CheckRedirect function fails
// or if there was an HTTP protocol error. A non-2xx response doesn't
Expand Down Expand Up @@ -770,11 +769,11 @@ func (c *Client) PostForm(url string, data url.Values) (resp *Response, err erro
// the following redirect codes, Head follows the redirect, up to a
// maximum of 10 redirects:
//
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
//
// Head is a wrapper around DefaultClient.Head
func Head(url string) (resp *Response, err error) {
Expand All @@ -785,11 +784,11 @@ func Head(url string) (resp *Response, err error) {
// following redirect codes, Head follows the redirect after calling the
// Client's CheckRedirect function:
//
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
// 301 (Moved Permanently)
// 302 (Found)
// 303 (See Other)
// 307 (Temporary Redirect)
// 308 (Permanent Redirect)
func (c *Client) HeadWithHost(url, host string) (resp *Response, err error) {
req, err := NewRequestWithHost("HEAD", url, host, nil)
if err != nil {
Expand All @@ -803,9 +802,9 @@ func (c *Client) Head(url string) (resp *Response, err error) {
}

// cancelTimerBody is an io.ReadCloser that wraps rc with two features:
// 1) on Read error or close, the stop func is called.
// 2) On Read failure, if reqDidTimeout is true, the error is wrapped and
// marked as net.Error that hit its timeout.
// 1. on Read error or close, the stop func is called.
// 2. On Read failure, if reqDidTimeout is true, the error is wrapped and
// marked as net.Error that hit its timeout.
type cancelTimerBody struct {
stop func() // stops the time.Timer waiting to cancel the request
rc io.ReadCloser
Expand Down
8 changes: 4 additions & 4 deletions lib/http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,9 +1067,9 @@ func TestClientHeadContentLength_h1(t *testing.T) {
}

/*
func TestClientHeadContentLength_h2(t *testing.T) {
testClientHeadContentLength(t, h2Mode)
}
func TestClientHeadContentLength_h2(t *testing.T) {
testClientHeadContentLength(t, h2Mode)
}
*/
func testClientHeadContentLength(t *testing.T, h2 bool) {
defer afterTest(t)
Expand Down Expand Up @@ -1379,7 +1379,7 @@ func TestClientTimeoutCancel(t *testing.T) {

func TestClientRedirectEatsBody_h1(t *testing.T) { testClientRedirectEatsBody(t, h1Mode) }

//func TestClientRedirectEatsBody_h2(t *testing.T) { testClientRedirectEatsBody(t, h2Mode) }
// func TestClientRedirectEatsBody_h2(t *testing.T) { testClientRedirectEatsBody(t, h2Mode) }
func testClientRedirectEatsBody(t *testing.T, h2 bool) {
setParallel(t)
defer afterTest(t)
Expand Down
Loading

0 comments on commit a97b459

Please sign in to comment.