You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
package main
import (
"http";
"io";
"time";
"fmt";
)
// yuck global :(
var Timeout bool;
//ugly timeout goroutine -- there's probably a better way to do this
func g_Timeout() {
time.Sleep(25000000000); // 25sec
Timeout = false;
}
// hello world, the web server
func HelloServer(c *http.Conn, req *http.Request) {
io.WriteString(c, "Hey there. In 25 seconds I should die...<br>");
Timeout = true;
go g_Timeout();
for Timeout {
time.Sleep(5000000); // 500ms (non-blocking?)
io.WriteString(c, ". "); // write to HTTP.Conn buffer
fmt.Printf("."); // write to stdout
}
io.WriteString(c, "I'm done");
}
func main() {
http.Handle("/test", http.HandlerFunc(HelloServer));
err := http.ListenAndServe(":9001", nil);
if err != nil {
panic("ListenAndServe: ", err.String())
}
}
What is the expected output? What do you see instead?
I expect the buffer to be drained every write increment (ie every 500ms),
but it appears that there's a certain threshold len(data) needs to reach
before the fd buffer is drained (and I consequently see it in my browser).
I didn't do much digging through the source so there might be a soft-limit
imposed? Correct me if I'm wrong.
What is your $GOOS? $GOARCH?
GOARCH=386
GOOS=linux
Which revision are you sync'ed to? (hg log -l 1)
4009:3732030c7584
Please provide any additional information below.
The http package also desperately needs a timeout function (there IS an fd
limit last time I checked :p). As a matter of fact, I might just make one.
The text was updated successfully, but these errors were encountered:
The connection output is buffered but we don't yet have a
Flush method. If you'd like to add one, please do, and see
http://golang.org/doc/contribute.html
by david.titarenco:
The text was updated successfully, but these errors were encountered: