mirror of
https://github.com/tinygo-org/net.git
synced 2026-08-16 10:43:29 +00:00
update 'net' package from 1.19.3 to 1.20.5
This commit is contained in:
committed by
deadprogram
parent
d0c97a5292
commit
c3616d9365
+17
-11
@@ -1,4 +1,4 @@
|
||||
// TINYGO: The following is copied and modified from Go 1.19.3 official implementation.
|
||||
// TINYGO: The following is copied and modified from Go 1.20.5 official implementation.
|
||||
|
||||
// TINYGO: Removed multipart stuff
|
||||
// TINYGO: Removed trace stuff
|
||||
@@ -51,9 +51,12 @@ type ProtocolError struct {
|
||||
func (pe *ProtocolError) Error() string { return pe.ErrorString }
|
||||
|
||||
var (
|
||||
// ErrNotSupported is returned by the Push method of Pusher
|
||||
// implementations to indicate that HTTP/2 Push support is not
|
||||
// available.
|
||||
// ErrNotSupported indicates that a feature is not supported.
|
||||
//
|
||||
// It is returned by ResponseController methods to indicate that
|
||||
// the handler does not support the method, and by the Push method
|
||||
// of Pusher implementations to indicate that HTTP/2 Push support
|
||||
// is not available.
|
||||
ErrNotSupported = &ProtocolError{"feature not supported"}
|
||||
|
||||
// Deprecated: ErrUnexpectedTrailer is no longer returned by
|
||||
@@ -319,7 +322,7 @@ type Request struct {
|
||||
Response *Response
|
||||
|
||||
// ctx is either the client or server context. It should only
|
||||
// be modified via copying the whole Request using WithContext.
|
||||
// be modified via copying the whole Request using Clone or WithContext.
|
||||
// It is unexported to prevent people from using Context wrong
|
||||
// and mutating the contexts held by callers of the same request.
|
||||
ctx context.Context
|
||||
@@ -330,7 +333,7 @@ type Request struct {
|
||||
}
|
||||
|
||||
// Context returns the request's context. To change the context, use
|
||||
// WithContext.
|
||||
// Clone or WithContext.
|
||||
//
|
||||
// The returned context is always non-nil; it defaults to the
|
||||
// background context.
|
||||
@@ -355,9 +358,7 @@ func (r *Request) Context() context.Context {
|
||||
// sending the request, and reading the response headers and body.
|
||||
//
|
||||
// To create a new request with a context, use NewRequestWithContext.
|
||||
// To change the context of a request, such as an incoming request you
|
||||
// want to modify before sending back out, use Request.Clone. Between
|
||||
// those two uses, it's rare to need WithContext.
|
||||
// To make a deep copy of a request with a new context, use Request.Clone.
|
||||
func (r *Request) WithContext(ctx context.Context) *Request {
|
||||
if ctx == nil {
|
||||
panic("nil context")
|
||||
@@ -424,6 +425,9 @@ var ErrNoCookie = errors.New("http: named cookie not present")
|
||||
// If multiple cookies match the given name, only one cookie will
|
||||
// be returned.
|
||||
func (r *Request) Cookie(name string) (*Cookie, error) {
|
||||
if name == "" {
|
||||
return nil, ErrNoCookie
|
||||
}
|
||||
for _, c := range readCookies(r.Header, name) {
|
||||
return c, nil
|
||||
}
|
||||
@@ -993,6 +997,8 @@ func ReadRequest(b *bufio.Reader) (*Request, error) {
|
||||
|
||||
func readRequest(b *bufio.Reader) (req *Request, err error) {
|
||||
tp := newTextprotoReader(b)
|
||||
defer putTextprotoReader(tp)
|
||||
|
||||
req = new(Request)
|
||||
|
||||
// First line: GET /index.html HTTP/1.0
|
||||
@@ -1001,7 +1007,6 @@ func readRequest(b *bufio.Reader) (req *Request, err error) {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
putTextprotoReader(tp)
|
||||
if err == io.EOF {
|
||||
err = io.ErrUnexpectedEOF
|
||||
}
|
||||
@@ -1132,7 +1137,8 @@ func (l *maxBytesReader) Read(p []byte) (n int, err error) {
|
||||
// If they asked for a 32KB byte read but only 5 bytes are
|
||||
// remaining, no need to read 32KB. 6 bytes will answer the
|
||||
// question of the whether we hit the limit or go past it.
|
||||
if int64(len(p)) > l.n+1 {
|
||||
// 0 < len(p) < 2^63
|
||||
if int64(len(p))-1 > l.n {
|
||||
p = p[:l.n+1]
|
||||
}
|
||||
n, err = l.r.Read(p)
|
||||
|
||||
Reference in New Issue
Block a user