Skip to content

net/http: problems or undocumented features dealing with handler timeout #6410

Closed
@snarglebritchet

Description

@snarglebritchet
What steps will reproduce the problem?

First problem: a http handler which delays longer than server.WriteTimeout just silently
sends nothing, not even a HTTP error header. This behaviour might be deliberate (on the
basis of "use a timeout handler instead"), but it needs documenting.

Second problem: responseWriter.Write() returns nil for err (a write success) if
WriteTimeout has been exceeded. (Contrast: using a http.TimeoutHandler, it returns
"http: Handler timeout" correctly.)

Third problem: using a TimeoutHandler, with the actual handler having the behaviour or
Write, long delay, Write, and a timeout set to fire during the delay, the first write
sends the headers and the written value, then the timeout fires and appends the timeout
text and fails to set headers (because they were already sent). The result is a jumble
of output. This is not exactly an error, but it's a thing that needs communicating in
the docs: that the TimeoutHandler uses the same ResponseWriter, and if you have written
anything it will be unable to rescind it.


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

8g


Which operating system are you using?

Ubuntu Linux 12.04 32 bit.


Which version are you using?  (run 'go version')

go version go1.1 linux/386

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions