aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/server.go
diff options
context:
space:
mode:
authorDavid Symonds <dsymonds@golang.org>2009-08-24 17:31:35 -0700
committerDavid Symonds <dsymonds@golang.org>2009-08-24 17:31:35 -0700
commit429157848f5ceae2572a7959ef38849cedcc2dde (patch)
tree781609124455c221d39b91a4ea2ff778aeaef413 /src/pkg/http/server.go
parentfdc4b4a47ffdd7bf9f1cba0f29c0efa44584f17d (diff)
downloadgo-429157848f5ceae2572a7959ef38849cedcc2dde.tar.xz
Wrap kludge text in HTML comments so the text/html output will remain valid HTML.
Be more conservative: only mess with text/html and text/plain output. R=rsc APPROVED=rsc DELTA=20 (12 added, 5 deleted, 3 changed) OCL=33806 CL=33812
Diffstat (limited to 'src/pkg/http/server.go')
-rw-r--r--src/pkg/http/server.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go
index 4ffdc780be..b7a81905c3 100644
--- a/src/pkg/http/server.go
+++ b/src/pkg/http/server.go
@@ -209,11 +209,6 @@ func errorKludge(c *Conn, req *Request) {
return;
}
- // Is it text? ("Content-Type" is always in the map)
- if s := c.header["Content-Type"]; len(s) < 5 || s[0:5] != "text/" {
- return;
- }
-
// Is it a broken browser?
var msg string;
switch agent := req.UserAgent; {
@@ -225,9 +220,21 @@ func errorKludge(c *Conn, req *Request) {
return;
}
msg += " would ignore this error page if this text weren't here.\n";
- io.WriteString(c, "\n");
- for c.written < min {
- io.WriteString(c, msg);
+
+ // Is it text? ("Content-Type" is always in the map)
+ baseType := strings.Split(c.header["Content-Type"], ";", 2)[0];
+ switch baseType {
+ case "text/html":
+ io.WriteString(c, "<!-- ");
+ for c.written < min {
+ io.WriteString(c, msg);
+ }
+ io.WriteString(c, " -->");
+ case "text/plain":
+ io.WriteString(c, "\n");
+ for c.written < min {
+ io.WriteString(c, msg);
+ }
}
}