mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00:00
gofmt-ify hash, http
(gofmt will be able to re-align map entries as in http nicely, eventually) R=rsc http://go/go-review/1018055
This commit is contained in:
parent
b16e6ab148
commit
ca2a69ea06
@ -21,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
// The size of an Adler-32 checksum in bytes.
|
||||
const Size = 4;
|
||||
const Size = 4
|
||||
|
||||
// digest represents the partial evaluation of a checksum.
|
||||
type digest struct {
|
||||
|
@ -57,12 +57,12 @@ func dirList(c *Conn, f *os.File) {
|
||||
for {
|
||||
dirs, err := f.Readdir(100);
|
||||
if err != nil || len(dirs) == 0 {
|
||||
break
|
||||
break;
|
||||
}
|
||||
for _, d := range dirs {
|
||||
name := d.Name;
|
||||
if d.IsDirectory() {
|
||||
name += "/"
|
||||
name += "/";
|
||||
}
|
||||
// TODO htmlescape
|
||||
fmt.Fprintf(c, "<a href=\"%s\">%s</a>\n", name, name);
|
||||
@ -181,4 +181,3 @@ func (f *fileHandler) ServeHTTP(c *Conn, r *Request) {
|
||||
path = path[len(f.prefix):len(path)];
|
||||
serveFileInternal(c, r, f.root + "/" + path, true);
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,6 @@ func TestRedirect(t *testing.T) {
|
||||
}
|
||||
r.Body.Close();
|
||||
if r.StatusCode != 200 || url != end {
|
||||
t.Fatalf("Get(%s) got status %d at %s, want 200 at %s", start, r.StatusCode, url, end)
|
||||
t.Fatalf("Get(%s) got status %d at %s, want 200 at %s", start, r.StatusCode, url, end);
|
||||
}
|
||||
}
|
||||
|
@ -98,4 +98,3 @@ var statusText = map[int]string {
|
||||
StatusGatewayTimeout: "Gateway Timeout",
|
||||
StatusHTTPVersionNotSupported: "HTTP Version Not Supported",
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ var urltests = []URLTest {
|
||||
"http://www.google.com",
|
||||
"http", "//www.google.com",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"", "", ""
|
||||
"", "", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// path
|
||||
URLTest{
|
||||
@ -41,9 +41,9 @@ var urltests = []URLTest {
|
||||
"http://www.google.com/",
|
||||
"http", "//www.google.com/",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "", ""
|
||||
"/", "", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// path with hex escaping... note that space roundtrips to +
|
||||
URLTest{
|
||||
@ -52,9 +52,9 @@ var urltests = []URLTest {
|
||||
"http://www.google.com/file%20one%26two",
|
||||
"http", "//www.google.com/file%20one%26two",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/file one&two", "", ""
|
||||
"/file one&two", "", "",
|
||||
},
|
||||
"http://www.google.com/file+one%26two"
|
||||
"http://www.google.com/file+one%26two",
|
||||
},
|
||||
// user
|
||||
URLTest{
|
||||
@ -63,9 +63,9 @@ var urltests = []URLTest {
|
||||
"ftp://webmaster@www.google.com/",
|
||||
"ftp", "//webmaster@www.google.com/",
|
||||
"webmaster@www.google.com", "webmaster", "www.google.com",
|
||||
"/", "", ""
|
||||
"/", "", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// escape sequence in username
|
||||
URLTest{
|
||||
@ -74,9 +74,9 @@ var urltests = []URLTest {
|
||||
"ftp://john%20doe@www.google.com/",
|
||||
"ftp", "//john%20doe@www.google.com/",
|
||||
"john doe@www.google.com", "john doe", "www.google.com",
|
||||
"/", "", ""
|
||||
"/", "", "",
|
||||
},
|
||||
"ftp://john+doe@www.google.com/"
|
||||
"ftp://john+doe@www.google.com/",
|
||||
},
|
||||
// query
|
||||
URLTest{
|
||||
@ -85,9 +85,9 @@ var urltests = []URLTest {
|
||||
"http://www.google.com/?q=go+language",
|
||||
"http", "//www.google.com/?q=go+language",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "q=go+language", ""
|
||||
"/", "q=go+language", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// query with hex escaping: NOT parsed
|
||||
URLTest{
|
||||
@ -96,9 +96,9 @@ var urltests = []URLTest {
|
||||
"http://www.google.com/?q=go%20language",
|
||||
"http", "//www.google.com/?q=go%20language",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "q=go%20language", ""
|
||||
"/", "q=go%20language", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// path without /, so no query parsing
|
||||
URLTest{
|
||||
@ -107,9 +107,9 @@ var urltests = []URLTest {
|
||||
"http:www.google.com/?q=go+language",
|
||||
"http", "www.google.com/?q=go+language",
|
||||
"", "", "",
|
||||
"www.google.com/?q=go language", "", ""
|
||||
"www.google.com/?q=go language", "", "",
|
||||
},
|
||||
"http:www.google.com/%3fq%3dgo+language"
|
||||
"http:www.google.com/%3fq%3dgo+language",
|
||||
},
|
||||
// non-authority
|
||||
URLTest{
|
||||
@ -118,9 +118,9 @@ var urltests = []URLTest {
|
||||
"mailto:/webmaster@golang.org",
|
||||
"mailto", "/webmaster@golang.org",
|
||||
"", "", "",
|
||||
"/webmaster@golang.org", "", ""
|
||||
"/webmaster@golang.org", "", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// non-authority
|
||||
URLTest{
|
||||
@ -129,9 +129,9 @@ var urltests = []URLTest {
|
||||
"mailto:webmaster@golang.org",
|
||||
"mailto", "webmaster@golang.org",
|
||||
"", "", "",
|
||||
"webmaster@golang.org", "", ""
|
||||
"webmaster@golang.org", "", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
// unescaped :// in query should not create a scheme
|
||||
URLTest{
|
||||
@ -140,9 +140,9 @@ var urltests = []URLTest {
|
||||
"/foo?query=http://bad",
|
||||
"", "/foo?query=http://bad",
|
||||
"", "", "",
|
||||
"/foo", "query=http://bad", ""
|
||||
"/foo", "query=http://bad", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
@ -153,9 +153,9 @@ var urlnofragtests = []URLTest {
|
||||
"http://www.google.com/?q=go+language#foo",
|
||||
"http", "//www.google.com/?q=go+language#foo",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "q=go+language#foo", ""
|
||||
"/", "q=go+language#foo", "",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
@ -166,9 +166,9 @@ var urlfragtests = []URLTest {
|
||||
"http://www.google.com/?q=go+language",
|
||||
"http", "//www.google.com/?q=go+language",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "q=go+language", "foo"
|
||||
"/", "q=go+language", "foo",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
URLTest{
|
||||
"http://www.google.com/?q=go+language#foo%26bar",
|
||||
@ -176,9 +176,9 @@ var urlfragtests = []URLTest {
|
||||
"http://www.google.com/?q=go+language",
|
||||
"http", "//www.google.com/?q=go+language",
|
||||
"www.google.com", "", "www.google.com",
|
||||
"/", "q=go+language", "foo&bar"
|
||||
"/", "q=go+language", "foo&bar",
|
||||
},
|
||||
""
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
@ -250,32 +250,32 @@ var unescapeTests = []URLEscapeTest {
|
||||
URLEscapeTest{
|
||||
"",
|
||||
"",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"abc",
|
||||
"abc",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"1%41",
|
||||
"1A",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"1%41%42%43",
|
||||
"1ABC",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"%4a",
|
||||
"J",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"%6F",
|
||||
"o",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"%", // not enough characters after %
|
||||
@ -317,27 +317,27 @@ var escapeTests = []URLEscapeTest {
|
||||
URLEscapeTest{
|
||||
"",
|
||||
"",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"abc",
|
||||
"abc",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"one two",
|
||||
"one+two",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
"10%",
|
||||
"10%25",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
URLEscapeTest{
|
||||
" ?&=#+%!",
|
||||
"+%3f%26%3d%23%2b%25!",
|
||||
nil
|
||||
nil,
|
||||
},
|
||||
}
|
||||
|
||||
@ -355,4 +355,3 @@ func TestURLEscape(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user