"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/net/http/transport_test.go" between
go1.16.4.src.tar.gz and go1.16.5.src.tar.gz

About: Google’s Go is a compiled, garbage-collected, concurrent programming language. Latest stable release (1.16).

transport_test.go  (go1.16.4.src):transport_test.go  (go1.16.5.src)
skipping to change at line 5317 skipping to change at line 5317
// Ensure that a missing status doesn't make the server panic // Ensure that a missing status doesn't make the server panic
// See Issue https://golang.org/issues/21701 // See Issue https://golang.org/issues/21701
func TestMissingStatusNoPanic(t *testing.T) { func TestMissingStatusNoPanic(t *testing.T) {
t.Parallel() t.Parallel()
const want = "unknown status code" const want = "unknown status code"
ln := newLocalListener(t) ln := newLocalListener(t)
addr := ln.Addr().String() addr := ln.Addr().String()
shutdown := make(chan bool, 1)
done := make(chan bool) done := make(chan bool)
fullAddrURL := fmt.Sprintf("http://%s", addr) fullAddrURL := fmt.Sprintf("http://%s", addr)
raw := "HTTP/1.1 400\r\n" + raw := "HTTP/1.1 400\r\n" +
"Date: Wed, 30 Aug 2017 19:09:27 GMT\r\n" + "Date: Wed, 30 Aug 2017 19:09:27 GMT\r\n" +
"Content-Type: text/html; charset=utf-8\r\n" + "Content-Type: text/html; charset=utf-8\r\n" +
"Content-Length: 10\r\n" + "Content-Length: 10\r\n" +
"Last-Modified: Wed, 30 Aug 2017 19:02:02 GMT\r\n" + "Last-Modified: Wed, 30 Aug 2017 19:02:02 GMT\r\n" +
"Vary: Accept-Encoding\r\n\r\n" + "Vary: Accept-Encoding\r\n\r\n" +
"Aloha Olaa" "Aloha Olaa"
go func() { go func() {
defer func() { defer close(done)
ln.Close()
close(done)
}()
conn, _ := ln.Accept() conn, _ := ln.Accept()
if conn != nil { if conn != nil {
io.WriteString(conn, raw) io.WriteString(conn, raw)
io.ReadAll(conn) io.ReadAll(conn)
conn.Close() conn.Close()
} }
}() }()
proxyURL, err := url.Parse(fullAddrURL) proxyURL, err := url.Parse(fullAddrURL)
skipping to change at line 5363 skipping to change at line 5359
} }
if res != nil && res.Body != nil { if res != nil && res.Body != nil {
io.Copy(io.Discard, res.Body) io.Copy(io.Discard, res.Body)
res.Body.Close() res.Body.Close()
} }
if err == nil || !strings.Contains(err.Error(), want) { if err == nil || !strings.Contains(err.Error(), want) {
t.Errorf("got=%v want=%q", err, want) t.Errorf("got=%v want=%q", err, want)
} }
close(shutdown) ln.Close()
<-done <-done
} }
func doFetchCheckPanic(tr *Transport, req *Request) (res *Response, err error, p anicked bool) { func doFetchCheckPanic(tr *Transport, req *Request) (res *Response, err error, p anicked bool) {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
panicked = true panicked = true
} }
}() }()
res, err = tr.RoundTrip(req) res, err = tr.RoundTrip(req)
 End of changes. 3 change blocks. 
6 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)