diff --git a/bytesconv.go b/bytesconv.go index d9e8c6b..c430a80 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -142,7 +142,7 @@ func ParseUfloat(buf []byte) (float64, error) { } b := buf var v uint64 - var offset float64 = 1.0 + var offset = 1.0 var pointFound bool for i, c := range b { if c < '0' || c > '9' { diff --git a/client_test.go b/client_test.go index 83612d4..c9aefc3 100644 --- a/client_test.go +++ b/client_test.go @@ -397,7 +397,7 @@ type readErrorConn struct { } func (r *readErrorConn) Read(p []byte) (int, error) { - return 0, fmt.Errorf("error!!!") + return 0, fmt.Errorf("error") } func (r *readErrorConn) Write(p []byte) (int, error) { diff --git a/compress.go b/compress.go index 1da5132..bf2cf70 100644 --- a/compress.go +++ b/compress.go @@ -123,7 +123,7 @@ func AppendGzipBytesLevel(dst, src []byte, level int) []byte { return w.b } -// WriteGzip writes gzipped p to w using the given compression level +// WriteGzipLevel writes gzipped p to w using the given compression level // and returns the number of compressed bytes written to w. // // Supported compression levels are: @@ -139,7 +139,7 @@ func WriteGzipLevel(w io.Writer, p []byte, level int) (int, error) { return n, err } -// WriteGzipLevel writes gzipped p to w and returns the number of compressed +// WriteGzip writes gzipped p to w and returns the number of compressed // bytes written to w. func WriteGzip(w io.Writer, p []byte) (int, error) { return WriteGzipLevel(w, p, CompressDefaultCompression) diff --git a/cookie.go b/cookie.go index e0ada00..9eb3587 100644 --- a/cookie.go +++ b/cookie.go @@ -73,7 +73,7 @@ func (c *Cookie) SetDomain(domain string) { c.domain = append(c.domain[:0], domain...) } -// SetDomain +// SetDomainBytes sets cookie domain. func (c *Cookie) SetDomainBytes(domain []byte) { c.domain = append(c.domain[:0], domain...) } diff --git a/header.go b/header.go index d4a516e..ce4745a 100644 --- a/header.go +++ b/header.go @@ -454,7 +454,7 @@ func (h *RequestHeader) SetMethod(method string) { h.method = append(h.method, method...) } -// SetMethod sets HTTP request method. +// SetMethodBytes sets HTTP request method. func (h *RequestHeader) SetMethodBytes(method []byte) { h.method = append(h.method[:0], method...) } @@ -475,7 +475,7 @@ func (h *RequestHeader) SetRequestURI(requestURI string) { h.requestURI = append(h.requestURI[:0], requestURI...) } -// SetRequestURI sets RequestURI for the first HTTP request line. +// SetRequestURIBytes sets RequestURI for the first HTTP request line. // RequestURI must be properly encoded. // Use URI.RequestURI for constructing proper RequestURI if unsure. func (h *RequestHeader) SetRequestURIBytes(requestURI []byte) { @@ -1347,7 +1347,7 @@ func (h *RequestHeader) parseFirstLine(buf []byte) (int, error) { h.noHTTP11 = true n = len(b) } else if n == 0 { - return 0, fmt.Errorf("RequestURI cannot be empty in %q", buf) + return 0, fmt.Errorf("requestURI cannot be empty in %q", buf) } else if !bytes.Equal(b[n+1:], strHTTP11) { h.noHTTP11 = true } @@ -1574,7 +1574,7 @@ func parseContentLength(b []byte) (int, error) { return -1, err } if n != len(b) { - return -1, fmt.Errorf("Non-numeric chars at the end of Content-Length") + return -1, fmt.Errorf("non-numeric chars at the end of Content-Length") } return v, nil } diff --git a/http.go b/http.go index 0895cfa..7480cef 100644 --- a/http.go +++ b/http.go @@ -688,7 +688,7 @@ func (resp *Response) mustSkipBody() bool { return resp.SkipBody || resp.Header.mustSkipContentLength() } -var errRequestHostRequired = errors.New("Missing required Host header in request") +var errRequestHostRequired = errors.New("missing required Host header in request") // Write writes request to w. // @@ -724,7 +724,7 @@ func (req *Request) Write(w *bufio.Writer) error { if hasBody { _, err = w.Write(body) } else if len(body) > 0 { - return fmt.Errorf("Non-zero body for non-POST request. body=%q", body) + return fmt.Errorf("non-zero body for non-POST request. body=%q", body) } return err } diff --git a/server.go b/server.go index 9f8c44e..0e8106e 100644 --- a/server.go +++ b/server.go @@ -231,7 +231,7 @@ func TimeoutHandler(h RequestHandler, timeout time.Duration, msg string) Request } } -// CompressHandlerLevel returns RequestHandler that transparently compresses +// CompressHandler returns RequestHandler that transparently compresses // response body generated by h if the request contains 'gzip' or 'deflate' // 'Accept-Encoding' header. func CompressHandler(h RequestHandler) RequestHandler { @@ -756,7 +756,8 @@ func (ctx *RequestCtx) Redirect(uri string, statusCode int) { ctx.redirect(u.FullURI(), statusCode) } -// Redirect sets 'Location: uri' response header and sets the given statusCode. +// RedirectBytes sets 'Location: uri' response header and sets +// the given statusCode. // // statusCode must have one of the following values: // @@ -1145,7 +1146,7 @@ var ( // ErrKeepaliveTimeout is returned from ServeConn // if the connection lifetime exceeds MaxKeepaliveDuration. - ErrKeepaliveTimeout = errors.New("MaxKeepaliveDuration exceeded") + ErrKeepaliveTimeout = errors.New("exceeded MaxKeepaliveDuration") ) // ServeConn serves HTTP requests from the given connection. diff --git a/uri.go b/uri.go index a59a910..32dcf65 100644 --- a/uri.go +++ b/uri.go @@ -132,7 +132,7 @@ func (x *URI) SetScheme(scheme string) { lowercaseBytes(x.scheme) } -// SetScheme sets URI scheme, i.e. http, https, ftp, etc. +// SetSchemeBytes sets URI scheme, i.e. http, https, ftp, etc. func (x *URI) SetSchemeBytes(scheme []byte) { x.scheme = append(x.scheme[:0], scheme...) lowercaseBytes(x.scheme) @@ -196,7 +196,7 @@ func (x *URI) parse(host, uri []byte, h *RequestHeader) { x.Reset() x.h = h - scheme, host, uri := splitHostUri(host, uri) + scheme, host, uri := splitHostURI(host, uri) x.scheme = append(x.scheme, scheme...) lowercaseBytes(x.scheme) x.host = append(x.host, host...) @@ -419,7 +419,7 @@ func (x *URI) String() string { return string(x.FullURI()) } -func splitHostUri(host, uri []byte) ([]byte, []byte, []byte) { +func splitHostURI(host, uri []byte) ([]byte, []byte, []byte) { n := bytes.Index(uri, strColonSlashSlash) if n < 0 { return strHTTP, host, uri @@ -437,7 +437,7 @@ func splitHostUri(host, uri []byte) ([]byte, []byte, []byte) { return scheme, uri[:n], uri[n:] } -// Returns query args. +// QueryArgs returns query args. func (x *URI) QueryArgs() *Args { x.parseQueryArgs() return &x.queryArgs