-
-
Notifications
You must be signed in to change notification settings - Fork 118
Open
Description
Lines 70 to 91 in eef9d7e
| buf := make([]byte, 0, 107) | |
| for { | |
| b, err := reader.ReadByte() | |
| if err != nil { | |
| return nil, fmt.Errorf(ErrCantReadVersion1Header.Error()+": %v", err) | |
| } | |
| buf = append(buf, b) | |
| if b == '\n' { | |
| // End of header found | |
| break | |
| } | |
| if len(buf) == 107 { | |
| // No delimiter in first 107 bytes | |
| return nil, ErrVersion1HeaderTooLong | |
| } | |
| if reader.Buffered() == 0 { | |
| // Header was not buffered in a single read. Since we can't | |
| // differentiate between genuine slow writers and DoS agents, | |
| // we abort. On healthy networks, this should never happen. | |
| return nil, ErrCantReadVersion1Header | |
| } | |
| } |
Instead of doing a single Peak or 107 ReadByte calls this should do one read syscall. into a buffer. and pass the rest of the buffer as a first read to the caller.
Metadata
Metadata
Assignees
Labels
No labels