mirror of
https://github.com/golang/net.git
synced 2026-03-31 10:27:08 +09:00
all: fix some comments
Including mismatched function names/struct names, repeated words, typos, etc. Change-Id: Ia576274bce6e6fbfe4d2fca6dcd6d31bf00936fb Reviewed-on: https://go-review.googlesource.com/c/net/+/683875 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
This commit is contained in:
@@ -184,7 +184,7 @@ func render1(w writer, n *Node) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Add initial newline where there is danger of a newline beging ignored.
|
||||
// Add initial newline where there is danger of a newline being ignored.
|
||||
if c := n.FirstChild; c != nil && c.Type == TextNode && strings.HasPrefix(c.Data, "\n") {
|
||||
switch n.Data {
|
||||
case "pre", "listing", "textarea":
|
||||
|
||||
@@ -908,7 +908,7 @@ func benchmarkTokenizer(b *testing.B, level int) {
|
||||
// not unescape < to <, or lower-case tag names and attribute keys.
|
||||
z.Raw()
|
||||
case lowLevel:
|
||||
// Caling z.Text, z.TagName and z.TagAttr returns []byte values
|
||||
// Calling z.Text, z.TagName and z.TagAttr returns []byte values
|
||||
// whose contents may change on the next call to z.Next.
|
||||
switch tt {
|
||||
case TextToken, CommentToken, DoctypeToken:
|
||||
|
||||
@@ -332,7 +332,7 @@ func (tc *testClientConn) greet(settings ...Setting) {
|
||||
// makeHeaderBlockFragment encodes headers in a form suitable for inclusion
|
||||
// in a HEADERS or CONTINUATION frame.
|
||||
//
|
||||
// It takes a list of alernating names and values.
|
||||
// It takes a list of alternating names and values.
|
||||
func (tc *testClientConn) makeHeaderBlockFragment(s ...string) []byte {
|
||||
if len(s)%2 != 0 {
|
||||
tc.t.Fatalf("uneven list of header name/value pairs")
|
||||
|
||||
@@ -347,7 +347,7 @@ func (fr *Framer) maxHeaderListSize() uint32 {
|
||||
func (f *Framer) startWrite(ftype FrameType, flags Flags, streamID uint32) {
|
||||
// Write the FrameHeader.
|
||||
f.wbuf = append(f.wbuf[:0],
|
||||
0, // 3 bytes of length, filled in in endWrite
|
||||
0, // 3 bytes of length, filled in endWrite
|
||||
0,
|
||||
0,
|
||||
byte(ftype),
|
||||
|
||||
@@ -875,7 +875,7 @@ func TestReadFrameOrder(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
if !((f.errDetail == nil && tt.wantErr == "") || (fmt.Sprint(f.errDetail) == tt.wantErr)) {
|
||||
t.Errorf("%d. framer eror = %q; want %q\n%s", i, f.errDetail, tt.wantErr, log.Bytes())
|
||||
t.Errorf("%d. framer error = %q; want %q\n%s", i, f.errDetail, tt.wantErr, log.Bytes())
|
||||
}
|
||||
if n < tt.atLeast {
|
||||
t.Errorf("%d. framer only read %d frames; want at least %d\n%s", i, n, tt.atLeast, log.Bytes())
|
||||
|
||||
@@ -100,7 +100,7 @@ func (c *synctestNetConn) LocalAddr() net.Addr {
|
||||
return c.loc.addr
|
||||
}
|
||||
|
||||
// LocalAddr returns the (fake) remote network address.
|
||||
// RemoteAddr returns the (fake) remote network address.
|
||||
func (c *synctestNetConn) RemoteAddr() net.Addr {
|
||||
return c.rem.addr
|
||||
}
|
||||
@@ -301,7 +301,7 @@ func (h *synctestNetConnHalf) setWriteError(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// deadlineContext converts a changable deadline (as in net.Conn.SetDeadline) into a Context.
|
||||
// deadlineContext converts a changeable deadline (as in net.Conn.SetDeadline) into a Context.
|
||||
type deadlineContext struct {
|
||||
mu sync.Mutex
|
||||
ctx context.Context
|
||||
|
||||
@@ -4297,7 +4297,7 @@ func TestTransportBodyRewindRace(t *testing.T) {
|
||||
for i := 0; i < clients; i++ {
|
||||
req, err := http.NewRequest("POST", ts.URL, bytes.NewBufferString("abcdef"))
|
||||
if err != nil {
|
||||
t.Fatalf("unexpect new request error: %v", err)
|
||||
t.Fatalf("unexpected new request error: %v", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
@@ -4336,7 +4336,7 @@ func TestTransportServerResetStreamAtHeaders(t *testing.T) {
|
||||
|
||||
req, err := http.NewRequest("POST", ts.URL, errorReader{io.EOF})
|
||||
if err != nil {
|
||||
t.Fatalf("unexpect new request error: %v", err)
|
||||
t.Fatalf("unexpected new request error: %v", err)
|
||||
}
|
||||
req.ContentLength = 0 // so transport is tempted to sniff it
|
||||
req.Header.Set("Expect", "100-continue")
|
||||
|
||||
@@ -25,7 +25,7 @@ type roundRobinWriteScheduler struct {
|
||||
}
|
||||
|
||||
// newRoundRobinWriteScheduler constructs a new write scheduler.
|
||||
// The round robin scheduler priorizes control frames
|
||||
// The round robin scheduler prioritizes control frames
|
||||
// like SETTINGS and PING over DATA frames.
|
||||
// When there are no control frames to send, it performs a round-robin
|
||||
// selection from the ready streams.
|
||||
|
||||
@@ -224,7 +224,7 @@ func (st *stream) readPrefixedInt(prefixLen uint8) (firstByte byte, v int64, err
|
||||
return firstByte, v, err
|
||||
}
|
||||
|
||||
// readPrefixedInt reads an RFC 7541 prefixed integer from st.
|
||||
// readPrefixedIntWithByte reads an RFC 7541 prefixed integer from st.
|
||||
// The first byte has already been read from the stream.
|
||||
func (st *stream) readPrefixedIntWithByte(firstByte byte, prefixLen uint8) (v int64, err error) {
|
||||
prefixMask := (byte(1) << prefixLen) - 1
|
||||
@@ -285,7 +285,7 @@ func (st *stream) readPrefixedString(prefixLen uint8) (firstByte byte, s string,
|
||||
return firstByte, s, err
|
||||
}
|
||||
|
||||
// readPrefixedString reads an RFC 7541 string from st.
|
||||
// readPrefixedStringWithByte reads an RFC 7541 string from st.
|
||||
// The first byte has already been read from the stream.
|
||||
func (st *stream) readPrefixedStringWithByte(firstByte byte, prefixLen uint8) (s string, err error) {
|
||||
size, err := st.readPrefixedIntWithByte(firstByte, prefixLen)
|
||||
|
||||
@@ -125,7 +125,7 @@ func TestRoundTripResponseContentLength(t *testing.T) {
|
||||
},
|
||||
wantContentLength: -1,
|
||||
}, {
|
||||
name: "unparseable",
|
||||
name: "unparsable",
|
||||
respHeader: http.Header{
|
||||
":status": []string{"200"},
|
||||
"content-length": []string{"1 1"},
|
||||
@@ -185,7 +185,7 @@ func TestRoundTripMalformedResponses(t *testing.T) {
|
||||
":status": []string{"200", "204"},
|
||||
},
|
||||
}, {
|
||||
name: "unparseable :status",
|
||||
name: "unparsable :status",
|
||||
respHeader: http.Header{
|
||||
":status": []string{"frogpants"},
|
||||
},
|
||||
|
||||
@@ -68,7 +68,7 @@ func newStream(qs *quic.Stream) *stream {
|
||||
// https://www.rfc-editor.org/rfc/rfc9114.html#section-7.1
|
||||
func (st *stream) readFrameHeader() (ftype frameType, err error) {
|
||||
if st.lim >= 0 {
|
||||
// We shoudn't call readFrameHeader before ending the previous frame.
|
||||
// We shouldn't call readFrameHeader before ending the previous frame.
|
||||
return 0, errH3FrameError
|
||||
}
|
||||
ftype, err = readVarint[frameType](st)
|
||||
|
||||
@@ -198,7 +198,7 @@ func TestStreamReadFrameHeaderPartial(t *testing.T) {
|
||||
st1.stream.CloseWrite()
|
||||
|
||||
if _, err := st2.readFrameHeader(); err == nil {
|
||||
t.Fatalf("%v/%v bytes of frame available: st.readFrameHeader() succeded; want error", i, len(frame))
|
||||
t.Fatalf("%v/%v bytes of frame available: st.readFrameHeader() succeeded; want error", i, len(frame))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ type EncodeHeadersParam struct {
|
||||
DefaultUserAgent string
|
||||
}
|
||||
|
||||
// EncodeHeadersParam is the result of EncodeHeaders.
|
||||
// EncodeHeadersResult is the result of EncodeHeaders.
|
||||
type EncodeHeadersResult struct {
|
||||
HasBody bool
|
||||
HasTrailers bool
|
||||
@@ -399,7 +399,7 @@ type ServerRequestResult struct {
|
||||
|
||||
// If the request should be rejected, this is a short string suitable for passing
|
||||
// to the http2 package's CountError function.
|
||||
// It might be a bit odd to return errors this way rather than returing an error,
|
||||
// It might be a bit odd to return errors this way rather than returning an error,
|
||||
// but this ensures we don't forget to include a CountError reason.
|
||||
InvalidReason string
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func ConsumeVarint(b []byte) (v uint64, n int) {
|
||||
return 0, -1
|
||||
}
|
||||
|
||||
// consumeVarintInt64 parses a variable-length integer as an int64.
|
||||
// ConsumeVarintInt64 parses a variable-length integer as an int64.
|
||||
func ConsumeVarintInt64(b []byte) (v int64, n int) {
|
||||
u, n := ConsumeVarint(b)
|
||||
// QUIC varints are 62-bits large, so this conversion can never overflow.
|
||||
|
||||
@@ -297,7 +297,7 @@ func (up *UsernamePassword) Authenticate(ctx context.Context, rw io.ReadWriter,
|
||||
b = append(b, up.Username...)
|
||||
b = append(b, byte(len(up.Password)))
|
||||
b = append(b, up.Password...)
|
||||
// TODO(mikio): handle IO deadlines and cancelation if
|
||||
// TODO(mikio): handle IO deadlines and cancellation if
|
||||
// necessary
|
||||
if _, err := rw.Write(b); err != nil {
|
||||
return err
|
||||
|
||||
@@ -142,7 +142,7 @@ func testPingPong(t *testing.T, c1, c2 net.Conn) {
|
||||
}
|
||||
|
||||
// testRacyRead tests that it is safe to mutate the input Read buffer
|
||||
// immediately after cancelation has occurred.
|
||||
// immediately after cancellation has occurred.
|
||||
func testRacyRead(t *testing.T, c1, c2 net.Conn) {
|
||||
go chunkedCopy(c2, rand.New(rand.NewSource(0)))
|
||||
|
||||
@@ -170,7 +170,7 @@ func testRacyRead(t *testing.T, c1, c2 net.Conn) {
|
||||
}
|
||||
|
||||
// testRacyWrite tests that it is safe to mutate the input Write buffer
|
||||
// immediately after cancelation has occurred.
|
||||
// immediately after cancellation has occurred.
|
||||
func testRacyWrite(t *testing.T, c1, c2 net.Conn) {
|
||||
go chunkedCopy(io.Discard, c2)
|
||||
|
||||
@@ -318,7 +318,7 @@ func testCloseTimeout(t *testing.T, c1, c2 net.Conn) {
|
||||
defer wg.Wait()
|
||||
wg.Add(3)
|
||||
|
||||
// Test for cancelation upon connection closure.
|
||||
// Test for cancellation upon connection closure.
|
||||
c1.SetDeadline(neverTimeout)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
@@ -109,7 +109,7 @@ func (c *Conn) setState(now time.Time, state connState) {
|
||||
}
|
||||
}
|
||||
|
||||
// confirmHandshake is called when the TLS handshake completes.
|
||||
// handshakeDone is called when the TLS handshake completes.
|
||||
func (c *Conn) handshakeDone() {
|
||||
close(c.lifetime.readyc)
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func (c *Conn) handle1RTT(now time.Time, dgram *datagram, buf []byte) int {
|
||||
p, err := parse1RTTPacket(buf, &c.keysAppData, connIDLen, pnumMax)
|
||||
if err != nil {
|
||||
// A localTransportError terminates the connection.
|
||||
// Other errors indicate an unparseable packet, but otherwise may be ignored.
|
||||
// Other errors indicate an unparsable packet, but otherwise may be ignored.
|
||||
if _, ok := err.(localTransportError); ok {
|
||||
c.abort(now, err)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ type testConn struct {
|
||||
// CRYPTO data produced by the conn's QUICConn is placed in
|
||||
// cryptoDataOut.
|
||||
//
|
||||
// The peerTLSConn is is a QUICConn representing the peer.
|
||||
// The peerTLSConn is a QUICConn representing the peer.
|
||||
// CRYPTO data produced by the conn is written to peerTLSConn,
|
||||
// and data produced by peerTLSConn is placed in cryptoDataIn.
|
||||
cryptoDataOut map[tls.QUICEncryptionLevel][]byte
|
||||
@@ -1095,7 +1095,7 @@ func (tc *testConnHooks) handleTLSEvent(e tls.QUICEvent) {
|
||||
case tls.QUICTransportParameters:
|
||||
p, err := unmarshalTransportParams(e.Data)
|
||||
if err != nil {
|
||||
tc.t.Logf("sent unparseable transport parameters %x %v", e.Data, err)
|
||||
tc.t.Logf("sent unparsable transport parameters %x %v", e.Data, err)
|
||||
} else {
|
||||
tc.sentTransportParameters = &p
|
||||
}
|
||||
@@ -1171,7 +1171,7 @@ func testPeerStatelessResetToken(seq int64) statelessResetToken {
|
||||
|
||||
// canceledContext returns a canceled Context.
|
||||
//
|
||||
// Functions which take a context preference progress over cancelation.
|
||||
// Functions which take a context preference progress over cancellation.
|
||||
// For example, a read with a canceled context will return data if any is available.
|
||||
// Tests use canceled contexts to perform non-blocking operations.
|
||||
func canceledContext() context.Context {
|
||||
|
||||
@@ -142,7 +142,7 @@ func (s *cryptoStream) sendData(off int64, b []byte) {
|
||||
func (s *cryptoStream) discardKeys() error {
|
||||
if s.in.end-s.in.start != 0 {
|
||||
// The peer sent some unprocessed CRYPTO data that we're about to discard.
|
||||
// Close the connetion with a TLS unexpected_message alert.
|
||||
// Close the connection with a TLS unexpected_message alert.
|
||||
// https://www.rfc-editor.org/rfc/rfc5246#section-7.2.2
|
||||
const unexpectedMessage = 10
|
||||
return localTransportError{
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
//
|
||||
// A [Stream] is a QUIC stream, an ordered, reliable byte stream.
|
||||
//
|
||||
// # Cancelation
|
||||
// # Cancellation
|
||||
//
|
||||
// All blocking operations may be canceled using a context.Context.
|
||||
// When performing an operation with a canceled context, the operation
|
||||
|
||||
@@ -178,7 +178,7 @@ func (c *lossState) nextNumber(space numberSpace) packetNumber {
|
||||
return c.spaces[space].nextNum
|
||||
}
|
||||
|
||||
// skipPacketNumber skips a packet number as a defense against optimistic ACK attacks.
|
||||
// skipNumber skips a packet number as a defense against optimistic ACK attacks.
|
||||
func (c *lossState) skipNumber(now time.Time, space numberSpace) {
|
||||
sent := newSentPacket()
|
||||
sent.num = c.spaces[space].nextNum
|
||||
|
||||
@@ -675,7 +675,7 @@ func TestLossPTONotSetWhenLossTimerSet(t *testing.T) {
|
||||
t.Logf("# PTO = smoothed_rtt + max(4*rttvar, 1ms)")
|
||||
test.wantTimeout(999 * time.Millisecond)
|
||||
|
||||
t.Logf("# ack of packet 1 starts loss timer for 0, PTO overidden")
|
||||
t.Logf("# ack of packet 1 starts loss timer for 0, PTO overridden")
|
||||
test.advance(333 * time.Millisecond)
|
||||
test.ack(initialSpace, 0*time.Millisecond, i64range[packetNumber]{1, 2})
|
||||
test.wantAck(initialSpace, 1)
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestQueue(t *testing.T) {
|
||||
|
||||
q := newQueue[int]()
|
||||
if got, err := q.get(nonblocking, nil); err != context.Canceled {
|
||||
t.Fatalf("q.get() = %v, %v, want nil, contex.Canceled", got, err)
|
||||
t.Fatalf("q.get() = %v, %v, want nil, context.Canceled", got, err)
|
||||
}
|
||||
|
||||
if !q.put(1) {
|
||||
@@ -33,7 +33,7 @@ func TestQueue(t *testing.T) {
|
||||
t.Fatalf("q.get() = %v, %v, want 2, nil", got, err)
|
||||
}
|
||||
if got, err := q.get(nonblocking, nil); err != context.Canceled {
|
||||
t.Fatalf("q.get() = %v, %v, want nil, contex.Canceled", got, err)
|
||||
t.Fatalf("q.get() = %v, %v, want nil, context.Canceled", got, err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
@@ -32,7 +32,7 @@ func (ss *skipState) init(c *Conn) {
|
||||
ss.updateNumberSkip(c)
|
||||
}
|
||||
|
||||
// shouldSkipAfter returns whether we should skip the given packet number.
|
||||
// shouldSkip returns whether we should skip the given packet number.
|
||||
func (ss *skipState) shouldSkip(num packetNumber) bool {
|
||||
return ss.skip == num
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (c *Conn) startTLS(now time.Time, initialConnID []byte, peerHostname string
|
||||
c.tls = tls.QUICServer(qconfig)
|
||||
}
|
||||
c.tls.SetTransportParameters(marshalTransportParameters(params))
|
||||
// TODO: We don't need or want a context for cancelation here,
|
||||
// TODO: We don't need or want a context for cancellation here,
|
||||
// but users can use a context to plumb values through to hooks defined
|
||||
// in the tls.Config. Pass through a context.
|
||||
if err := c.tls.Start(context.TODO()); err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ func newTestTLSConfig(side connSide) *tls.Config {
|
||||
MinVersion: tls.VersionTLS13,
|
||||
// Default key exchange mechanisms as of Go 1.23 minus X25519Kyber768Draft00,
|
||||
// which bloats the client hello enough to spill into a second datagram.
|
||||
// Tests were written with the assuption each flight in the handshake
|
||||
// Tests were written with the assumption each flight in the handshake
|
||||
// fits in one datagram, and it's simpler to keep that property.
|
||||
CurvePreferences: []tls.CurveID{
|
||||
tls.X25519, tls.CurveP256, tls.CurveP384, tls.CurveP521,
|
||||
|
||||
Reference in New Issue
Block a user