Skip to content

Commit

Permalink
improved explaination of testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunKoyalwar committed Oct 31, 2023
1 parent e7dbc7c commit 2d91647
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions reader/conn_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ func ConnReadN(ctx context.Context, reader io.Reader, N int64) ([]byte, error) {
var readErr error
pr, pw := io.Pipe()

// context: in nuclei network protocol when reading all available data
// from connection it might timeout after sending all data
// see: TestConnReadN#6 for example of this
// in such case what we desire is that even though it timeout out
// but returned some data then we should return that data and hide the error
// we use io.Pipe() with goroutine to avoid race conditions
// When using the Nuclei network protocol to read all available data from a connection,
// there may be a timeout error after data has been sent by server. In this scenario,
// we should return the data and ignore the error (if it is a timeout error).
// To avoid race conditions, we use io.Pipe() along with a goroutine.
// For an example of this scenario, refer to TestConnReadN#6.

go func() {
defer pw.Close()
Expand Down

0 comments on commit 2d91647

Please sign in to comment.