Skip to content

Commit 5b9cfb9

Browse files
committedSep 19, 2020
Minor fix
1 parent a861f4b commit 5b9cfb9

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed
 

‎relay.go

+4-17
Original file line numberDiff line numberDiff line change
@@ -719,24 +719,15 @@ func (re *remoteConn) doRemote(lo localConn, out *net.Conn, network string, time
719719
if lo.mode == "H" && re.firstReq != nil {
720720
firstResp, err = http.ReadResponse(bufOut, re.firstReq)
721721
ttfb = time.Since(sentTime)
722-
// Continue reading for a short period of time to detect delayed reset
723-
// This is obviously insufficient, need to come up with a better way
724-
if err == nil && route == 1 && !re.ruleBased {
725-
(*out).SetReadDeadline(time.Now().Add(time.Millisecond * 100))
726-
_, err = bufOut.ReadByte()
727-
if err == nil {
728-
bufOut.UnreadByte()
729-
}
730-
if err != nil && strings.Contains(err.Error(), "time") {
731-
err = nil
732-
}
733-
}
734722
} else {
735723
n, err = bufOut.Read(firstIn)
736724
ttfb = time.Since(sentTime)
725+
if n > 0 && *verbose {
726+
logger.Printf("%s %5d: * %d First %d bytes from server. TTFB %d ms.", lo.mode, lo.total, route, n, ttfb.Milliseconds())
727+
}
737728
// Continue reading for a short period of time to detect delayed reset
738729
if err == nil && route == 1 && !re.ruleBased && n > 0 && n < initialSize {
739-
(*out).SetReadDeadline(time.Now().Add(time.Millisecond * 100))
730+
(*out).SetReadDeadline(time.Now().Add(time.Millisecond * 50))
740731
var n1 int
741732
n1, err = io.ReadFull(bufOut, firstIn[n:])
742733
n += n1
@@ -788,7 +779,6 @@ func (re *remoteConn) doRemote(lo localConn, out *net.Conn, network string, time
788779
} else {
789780
// If there is response, remove full flag
790781
re.firstIsFull = false
791-
// Check response validity
792782
if lo.mode == "H" && re.firstReq != nil {
793783
if *verbose {
794784
logger.Printf("H %5d: * %d HTTP Status %s Content-length %d. TTFB %d ms.", lo.total, route, firstResp.Status, firstResp.ContentLength, ttfb.Milliseconds())
@@ -801,9 +791,6 @@ func (re *remoteConn) doRemote(lo localConn, out *net.Conn, network string, time
801791
return
802792
}
803793
} else {
804-
if *verbose {
805-
logger.Printf("%s %5d: * %d First %d bytes from server. TTFB %d ms.", lo.mode, lo.total, route, n, ttfb.Milliseconds())
806-
}
807794
if re.firstReq != nil {
808795
if resp, err := readResponseStatus(bufio.NewReader(bytes.NewReader(firstIn[:n]))); err == nil {
809796
if *verbose {

0 commit comments

Comments
 (0)
Please sign in to comment.