Commit 63224cab authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: document and deprecate type and errors of type ProtocolError

Clean up & document the ProtocolError gunk.

Fixes #17558

Change-Id: I5e54c25257907c9cac7433f7a5bdfb176e8c3eee
Reviewed-on: https://go-review.googlesource.com/33096Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 41027cc4
...@@ -15,8 +15,13 @@ import ( ...@@ -15,8 +15,13 @@ import (
) )
var ( var (
// Deprecated: No longer used.
ErrPersistEOF = &http.ProtocolError{ErrorString: "persistent connection closed"} ErrPersistEOF = &http.ProtocolError{ErrorString: "persistent connection closed"}
// Deprecated: No longer used.
ErrClosed = &http.ProtocolError{ErrorString: "connection closed by user"} ErrClosed = &http.ProtocolError{ErrorString: "connection closed by user"}
// Deprecated: No longer used.
ErrPipeline = &http.ProtocolError{ErrorString: "pipeline error"} ErrPipeline = &http.ProtocolError{ErrorString: "pipeline error"}
) )
......
...@@ -39,21 +39,40 @@ const ( ...@@ -39,21 +39,40 @@ const (
// is either not present in the request or not a file field. // is either not present in the request or not a file field.
var ErrMissingFile = errors.New("http: no such file") var ErrMissingFile = errors.New("http: no such file")
// HTTP request parsing errors. // ProtocolError represents an HTTP protocol error.
//
// Deprecated: Not all errors in the http package related to protocol errors
// are of type ProtocolError.
type ProtocolError struct { type ProtocolError struct {
ErrorString string ErrorString string
} }
func (err *ProtocolError) Error() string { return err.ErrorString } func (pe *ProtocolError) Error() string { return pe.ErrorString }
var ( var (
ErrHeaderTooLong = &ProtocolError{"header too long"} // ErrNotSupported is returned by the Push method of Pusher
ErrShortBody = &ProtocolError{"entity body too short"} // implementations to indicate that HTTP/2 Push support is not
// available.
ErrNotSupported = &ProtocolError{"feature not supported"} ErrNotSupported = &ProtocolError{"feature not supported"}
// ErrUnexpectedTrailer is returned by the Transport when a server
// replies with a Trailer header, but without a chunked reply.
ErrUnexpectedTrailer = &ProtocolError{"trailer header without chunked transfer encoding"} ErrUnexpectedTrailer = &ProtocolError{"trailer header without chunked transfer encoding"}
ErrMissingContentLength = &ProtocolError{"missing ContentLength in HEAD response"}
ErrNotMultipart = &ProtocolError{"request Content-Type isn't multipart/form-data"} // ErrMissingBoundary is returned by Request.MultipartReader when the
// request's Content-Type does not include a "boundary" parameter.
ErrMissingBoundary = &ProtocolError{"no multipart boundary param in Content-Type"} ErrMissingBoundary = &ProtocolError{"no multipart boundary param in Content-Type"}
// ErrNotMultipart is returned by Request.MultipartReader when the
// request's Content-Type is not multipart/form-data.
ErrNotMultipart = &ProtocolError{"request Content-Type isn't multipart/form-data"}
// Deprecated: ErrHeaderTooLong is not used.
ErrHeaderTooLong = &ProtocolError{"header too long"}
// Deprecated: ErrShortBody is not used.
ErrShortBody = &ProtocolError{"entity body too short"}
// Deprecated: ErrMissingContentLength is not used.
ErrMissingContentLength = &ProtocolError{"missing ContentLength in HEAD response"}
) )
type badStringError struct { type badStringError struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment