Skip to content

HTTP client panics issuing HEAD request when response reports gzip content encoding #1804

@gopherbot

Description

@gopherbot

by eivind@uggedal.com:

What steps will reproduce the problem?

1.
  cat > head_with_gzip_response_bug.go << 'EOF'
  package main
  import "http"
  func main () {
    http.Head("http://uggedal.com/";)
  }
  EOF

2.
  6g head_with_gzip_response_bug.go && 6l -o head_with_gzip_response_bug head_with_gzip_response_bug.6 && ./head_with_gzip_response_bug

What is the expected output?

Nothing, success return.

What do you see instead?

panic: interface conversion: io.ReadCloser is *http.body, not *http.bodyEOFSignal

runtime.panic+0xac /home/eivind/dev/go/src/pkg/runtime/proc.c:1060
    runtime.panic(0x52e920, 0xf84000de00)
assertI2Tret+0x107 /home/eivind/dev/go/src/pkg/runtime/iface.c:251
    assertI2Tret(0x5218a0, 0xf8400a20f0, 0xf8400a2060, 0x7fe43ecd1d30, 0xf8400981c0, ...)
runtime.assertI2T+0x33 /home/eivind/dev/go/src/pkg/runtime/iface.c:231
    runtime.assertI2T(0x5218a0, 0xf8400a20f0, 0xf8400a2060, 0x70697a6700000004)
http.*persistConn·roundTrip+0x34d /home/eivind/dev/go/src/pkg/http/transport.go:546
    http.*persistConn·roundTrip(0xf840027d20, 0xf84002d4b0, 0x0, 0x0, 0x0, ...)
http.*Transport·RoundTrip+0x200 /home/eivind/dev/go/src/pkg/http/transport.go:79
    http.*Transport·RoundTrip(0xf84000c840, 0xf84002d4b0, 0x0, 0x0, 0x0, ...)
http.send+0x2c0 /home/eivind/dev/go/src/pkg/http/client.go:108
    http.send(0xf84002d4b0, 0xf840042000, 0xf84000c840, 0x0, 0x0, ...)
http.*Client·Head+0xc5 /home/eivind/dev/go/src/pkg/http/client.go:307
    http.*Client·Head(0xf84000c820, 0x5576b4, 0x13, 0x0, 0x0, ...)
http.Head+0x51 /home/eivind/dev/go/src/pkg/http/client.go:297
    http.Head(0x5576b4, 0x7074746800000013, 0x6075c8, 0x0, 0x0, ...)
main.main+0x2c /home/eivind/dev/wasitup/goclient/head_with_gzip_response_bug.go:6
    main.main()
runtime.mainstart+0xf /home/eivind/dev/go/src/pkg/runtime/amd64/asm.s:77
    runtime.mainstart()
runtime.goexit /home/eivind/dev/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
_rt0_amd64+0x8e /home/eivind/dev/go/src/pkg/runtime/amd64/asm.s:64

goroutine 3 [1]:
runtime.gosched+0x5c /home/eivind/dev/go/src/pkg/runtime/proc.c:603
    runtime.gosched()
runtime.exitsyscall+0x73 /home/eivind/dev/go/src/pkg/runtime/proc.c:683
    runtime.exitsyscall()
syscall.Syscall+0x4b /home/eivind/dev/go/src/pkg/syscall/asm_linux_amd64.s:30
    syscall.Syscall()
syscall.Read+0x62 /home/eivind/dev/go/src/pkg/syscall/zsyscall_linux_amd64.go:498
    syscall.Read(0xf800000003, 0xf840029000, 0x100000001000, 0x404831, 0xf84000dcd8, ...)
net.*netFD·Read+0x172 /home/eivind/dev/go/src/pkg/net/fd.go:378
    net.*netFD·Read(0xf840038140, 0xf840029000, 0x100000001000, 0x100000000, 0x0, ...)
net.*TCPConn·Read+0x95 /home/eivind/dev/go/src/pkg/net/tcpsock.go:94
    net.*TCPConn·Read(0xf840000128, 0xf840029000, 0x100000001000, 0xf2c00000000, 0x0, ...)
bufio.*Reader·fill+0xf6 /home/eivind/dev/go/src/pkg/bufio/bufio.go:97
    bufio.*Reader·fill(0xf840033fc0, 0x0)
bufio.*Reader·Peek+0xbc /home/eivind/dev/go/src/pkg/bufio/bufio.go:116
    bufio.*Reader·Peek(0xf840033fc0, 0xf800000001, 0x0, 0x0, 0xf840001500, ...)
http.*persistConn·readLoop+0x78 /home/eivind/dev/go/src/pkg/http/transport.go:433
    http.*persistConn·readLoop(0xf840027d20, 0x0)
runtime.goexit /home/eivind/dev/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
http.*Transport·getConn+0x610 /home/eivind/dev/go/src/pkg/http/transport.go:289

goroutine 2 [3]:
runtime.entersyscall+0x78 /home/eivind/dev/go/src/pkg/runtime/proc.c:639
    runtime.entersyscall()
syscall.Syscall6+0x5 /home/eivind/dev/go/src/pkg/syscall/asm_linux_amd64.s:40
    syscall.Syscall6()
syscall.EpollWait+0x89 /home/eivind/dev/go/src/pkg/syscall/zsyscall_linux_amd64.go:200
    syscall.EpollWait(0xf800000007, 0xf84001df30, 0xa0000000a, 0xffffffff, 0xc, ...)
net.*pollster·WaitFD+0x115 /home/eivind/dev/go/src/pkg/net/fd_linux.go:130
    net.*pollster·WaitFD(0xf84001df20, 0xf84001c7c0, 0x0, 0x7200000003, 0x0, ...)
net.*pollServer·Run+0xe0 /home/eivind/dev/go/src/pkg/net/fd.go:226
    net.*pollServer·Run(0xf84001c7c0, 0x0)
runtime.goexit /home/eivind/dev/go/src/pkg/runtime/proc.c:178
    runtime.goexit()
----- goroutine created by -----
net.newPollServer+0x328 /home/eivind/dev/go/src/pkg/net/newpollserver.go:39


Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Debian GNU/Linux 6.0 Squeeze

Which revision are you using?  (hg identify)

2887dd36b6f8+ tip

Please provide any additional information below.

See attached patch with test case

Attachments:

  1. head_with_gzip_response_bug.patch (1356 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions