1
0
mirror of https://github.com/golang/go synced 2024-10-04 22:21:22 -06:00
Commit Graph

2718 Commits

Author SHA1 Message Date
Russ Cox
c4407b7552 http: close after responding to HTTP/1.0 request without Connection: keep-alive
R=adg
CC=golang-dev
https://golang.org/cl/4245065
2011-03-07 00:14:40 -05:00
Russ Cox
0db312b6a8 http: use Header type consistently
R=bradfitzgo, dsymonds
CC=golang-dev
https://golang.org/cl/4244053
2011-03-06 23:02:29 -05:00
Brad Fitzpatrick
545a1eef6a http: add Hijacker type; remove Hijack from ResponseWriter
The Hijack functionality wasn't removed, but now you have
to test if your ResponseWriter is also a Hijacker:

func ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    if hj, ok := rw.(http.Hijacker); ok {
        hj.Hijack(..)
    }
}

R=rsc
CC=golang-dev
https://golang.org/cl/4245064
2011-03-06 18:59:50 -08:00
Russ Cox
2b4a9603d3 io/ioutil: use filepath.Join, handle trailing / in $TMPDIR
R=niemeyer
CC=golang-dev
https://golang.org/cl/4256057
2011-03-06 21:52:37 -05:00
Alex Brainman
94401f524e path/filepath: disable test on windows to fix build
R=golang-dev, rsc1
CC=golang-dev
https://golang.org/cl/4235054
2011-03-07 12:23:57 +11:00
Brad Fitzpatrick
6193e0ba00 mime/multipart: switch from map to MIMEHeader
R=rsc
CC=golang-dev
https://golang.org/cl/4253058
2011-03-06 15:12:03 -08:00
Gustavo Niemeyer
04ca4f8242 path/filepath: new OS-specific path support
The path package now contains only functions which
deal with slashed paths, sensible for any OS when dealing
with network paths or URLs.  OS-specific functionality
has been moved into the new path/filepath package.

This also includes fixes for godoc, goinstall and other
packages which were mixing slashed and OS-specific paths.

R=rsc, gri, mattn, brainman
CC=golang-dev
https://golang.org/cl/4252044
2011-03-06 17:33:23 -05:00
Robert Hencke
ce65b72508 websocket: use httptest.Server for tests
R=rsc
CC=golang-dev
https://golang.org/cl/4266044
2011-03-06 17:05:12 -05:00
Petar Maymounkov
6afe7eba32 http: add cookie support
R=rsc1, mattn, bradfitzwork, pascal, bradfitzgo
CC=golang-dev
https://golang.org/cl/4214042
2011-03-06 15:02:06 -05:00
Devon H. O'Dell
eeb8d00c86 syscall: work around FreeBSD execve kernel bug
FreeBSD's execve implementation has an integer underflow in a bounds test which
causes it to erroneously think the argument list is too long when argv[0] is
longer than interpreter + path.

R=rsc, bradfitz, rsc1
CC=golang-dev
https://golang.org/cl/4259056
2011-03-06 14:57:05 -05:00
Rob Pike
9e25eccf48 gob: clean up getTypeInfo (address a TODO)
also fix a caching bug.

R=rsc
CC=golang-dev
https://golang.org/cl/4261049
2011-03-06 10:50:07 -08:00
Russ Cox
255b538152 http/cgi: skip test if perl or CGI.pm not available
R=bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4264047
2011-03-06 11:23:47 -05:00
Robert Hencke
ff3ef8a963 fmt: trivial cleanup
R=golang-dev, bradfitzgo
CC=golang-dev
https://golang.org/cl/4235052
2011-03-05 17:55:53 -08:00
Rob Pike
369c48cafb gob: don't send type information about unexported fields.
A change a while back stop sending data for unexported fields
but due to an oversight the type info was being sent also. It's
inconsequential but wrong to do that.

R=rsc, rh
CC=golang-dev
https://golang.org/cl/4252058
2011-03-05 16:05:35 -08:00
Brad Fitzpatrick
bfd3d81b92 httptest: fix docs out-of-sync from earlier renaming
R=rh
CC=golang-dev
https://golang.org/cl/4239060
2011-03-05 15:43:26 -08:00
Brad Fitzpatrick
f88abdad0f httptest: introduce TempServer, clean up tests
This also breaks fs_test into two parts
as the range tests test http's private httpRange
and I had to change the fs_test package from
"http" to "http_test" to use httptest which otherwise
has a cyclic depedency back on http.

Aside: we should start exposing the Range
stuff in the future.

R=rsc
CC=golang-dev
https://golang.org/cl/4261047
2011-03-05 13:51:35 -08:00
Petar Maymounkov
5db0a8b9ef http: fixed race condition in persist.go
R=rsc, bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4266042
2011-03-05 14:44:05 -05:00
Russ Cox
7bc90eda69 http: fix, use WriteProxy
Fixes #53.

R=bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4240075
2011-03-05 14:35:15 -05:00
Russ Cox
d044674a0d compress/flate: fix test
The test was checking for a buffer to be empty but
actually racing with the background goroutine that
was emptying it.  Left a comment so that the check
is not reintroduced later.

Fixes #1557.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4248063
2011-03-05 14:35:03 -05:00
David Symonds
4c30ca067d time: split os-dependent part into sys.go.
R=rsc
CC=golang-dev
https://golang.org/cl/4259051
2011-03-04 19:57:39 -08:00
Rob Pike
9442e9518d gob: enable the GobEncoder and GobDecoder interfaces.
These allow data items to control their own representation.

For now, the implementation requires that the value passed
to Encode and Decode must be exactly the type of the
methods' receiver; it cannot be, for instance, T if the receiver
is of type *T.  This will be fixed in a later CL.

R=rsc
CC=golang-dev
https://golang.org/cl/4235051
2011-03-04 14:18:52 -08:00
Brad Fitzpatrick
99f17aa0b8 http/cgi: skip tests on Windows
The tests require Perl, not commonly installed on Windows.

R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4239057
2011-03-04 14:12:39 -08:00
Russ Cox
e339d27db7 runtime: make printf work on misaligned stack
(Shouldn't happen, but if it does, it's useful to be
able to use printf to debug it.)

R=r
CC=golang-dev
https://golang.org/cl/4250057
2011-03-04 15:42:39 -05:00
Rob Pike
c91daefb24 gob: beginning of support for GobEncoder/GobDecoder interfaces.
This allows a data item that can marshal itself to be transmitted by its
own encoding, enabling some types to be handled that cannot be
normally, plus providing a way to use gobs on data with unexported
fields.

In this CL, the necessary methods are protected by leading _, so only
package gob can use the facilities (in its tests, of course); this
code is not ready for real use yet.  I could be talked into enabling
it for experimentation, though.  The main drawback is that the
methods must be implemented by the actual type passed through,
not by an indirection from it.  For instance, if *T implements
GobEncoder, you must send a *T, not a T.  This will be addressed
in due course.

Also there is improved commentary and a couple of unrelated
minor bug fixes.

R=rsc
CC=golang-dev
https://golang.org/cl/4243056
2011-03-04 12:25:18 -08:00
Brad Fitzpatrick
7b563be516 http: rename ClientTransport to Transport
http.Transport looks nicer, and ServerTransport
doesn't make much sense anyway.

R=rsc
CC=golang-dev
https://golang.org/cl/4239056
2011-03-04 11:41:57 -08:00
Brad Fitzpatrick
da679db0f1 http: add packages http/cgi and http/httptest
R=rsc, adg, jnw, bradfitzwork
CC=golang-dev
https://golang.org/cl/4247048
2011-03-04 10:55:47 -08:00
Brad Fitzpatrick
38a105e48a http: change localhost URL; maybe fix Windows
R=golang-dev, rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4259048
2011-03-03 13:29:31 -08:00
Brad Fitzpatrick
61fd11ef96 http: allow handlers to send non-chunked responses
Currently all http handlers reply to HTTP/1.1 requests with
chunked responses.  This patch allows handlers to opt-out of
that behavior by pre-declaring their Content-Length (which is
then enforced) and unsetting their Transfer-Encoding or
setting it to the "identity" encoding.

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4245058
2011-03-03 12:22:13 -08:00
Russ Cox
9ebe384b71 io/ioutil: add TempDir
It's a little confusing that os.TempDir and ioutil.TempDir have
different meanings.  I don't know what to change the names to,
if anything.  At least they also have different signatures.

R=golang-dev, bradfitzgo, r, gri
CC=golang-dev
https://golang.org/cl/4247051
2011-03-03 14:51:49 -05:00
Roger Peppe
da833474f5 testing: run GC before each benchmark run.
R=r, rh, gri, rsc
CC=golang-dev
https://golang.org/cl/4237055
2011-03-03 11:26:53 -08:00
Roger Peppe
5bd284e868 fmt: make recursive scan more efficient.
Detect when scan is being called recursively and
re-use the same scan state.

On my machine, for a recursion-heavy benchmark, this
results in 44x speed up. This does impose a 4% penalty
on the non-recursive case, which can be removed by
heap-allocating the saved state, at 40% performance penalty
on the recursive case. Either way is fine with me.

R=r
CC=golang-dev
https://golang.org/cl/4253049
2011-03-03 10:43:29 -08:00
Russ Cox
e46acb091f reflect: add PtrTo, add Value.Addr (old Addr is now UnsafeAddr)
This change makes it possible to take the address of a
struct field or slice element in order to call a method that
requires a pointer receiver.

Existing code that uses the Value.Addr method will have
to change (as gob does in this CL) to call UnsafeAddr instead.

R=r, rog
CC=golang-dev
https://golang.org/cl/4239052
2011-03-03 13:20:17 -05:00
Adam Langley
e7fa307902 bzip2: speed up decompression.
This borrows a trick from the bzip2 source and effects a decent speed
up when decompressing highly compressed sources. Rather than unshuffle
the BTW block when performing the IBTW, a linked-list is threaded
through the array, in place. This improves cache hit rates.

R=bradfitzgo, bradfitzwork, cw
CC=golang-dev
https://golang.org/cl/4247047
2011-03-03 09:13:06 -05:00
Nigel Tao
7483c6ee3c image: add a decoding test for common file formats.
The test image was converted from doc/video-001.png using the
convert command line tool (ImageMagick 6.5.7-8) at -quality 100.

R=r, nigeltao_gnome
CC=golang-dev
https://golang.org/cl/4259047
2011-03-03 20:35:49 +11:00
Rob Pike
68add46af7 unsafe: fix the documentation
Reflection is about Pointer, not uintptr.
Also clarify that Reflect and Unreflect are indirect.

R=rsc
CC=golang-dev
https://golang.org/cl/4254052
2011-03-02 19:39:08 -08:00
Dave Cheney
ff1d89d600 runtime: fix unused variable warning
R=rsc
CC=golang-dev
https://golang.org/cl/4188043
2011-03-02 15:29:13 -05:00
Yasuhiro Matsumoto
1a6b1dd0de xml: fix typo in test.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4218042
2011-03-02 15:05:52 -05:00
Roger Peppe
81bfbe9333 fmt: allow recursive calls to Fscan etc.
Add a new Read method to ScanState so that it
satisfies the io.Reader interface; rename
Getrune and Ungetrune to ReadRune and UnreadRune.
Make sure ReadRune does not read past width restrictions;
remove now-unnecessary Width method from ScanState.
Also make the documentation a little clearer as to
how ReadRune and UnreadRune are used.

R=r, r2
CC=golang-dev
https://golang.org/cl/4240056
2011-03-02 10:54:23 -08:00
Russ Cox
324cc3d040 runtime: record goroutine creation pc and display in traceback
package main

func main() {
        go func() { *(*int)(nil) = 0 }()
        select{}
}

panic: runtime error: invalid memory address or nil pointer dereference

[signal 0xb code=0x1 addr=0x0 pc=0x1c96]

runtime.panic+0xac /Users/rsc/g/go/src/pkg/runtime/proc.c:1083
        runtime.panic(0x11bf0, 0xf8400011f0)
runtime.panicstring+0xa3 /Users/rsc/g/go/src/pkg/runtime/runtime.c:116
        runtime.panicstring(0x29a57, 0x0)
runtime.sigpanic+0x144 /Users/rsc/g/go/src/pkg/runtime/darwin/thread.c:470
        runtime.sigpanic()
main._func_001+0x16 /Users/rsc/g/go/src/pkg/runtime/x.go:188
        main._func_001()
runtime.goexit /Users/rsc/g/go/src/pkg/runtime/proc.c:150
        runtime.goexit()
----- goroutine created by -----
main.main+0x3d /Users/rsc/g/go/src/pkg/runtime/x.go:4

goroutine 1 [4]:
runtime.gosched+0x77 /Users/rsc/g/go/src/pkg/runtime/proc.c:598
        runtime.gosched()
runtime.block+0x27 /Users/rsc/g/go/src/pkg/runtime/chan.c:680
        runtime.block()
main.main+0x44 /Users/rsc/g/go/src/pkg/runtime/x.go:5
        main.main()
runtime.mainstart+0xf /Users/rsc/g/go/src/pkg/runtime/amd64/asm.s:77
        runtime.mainstart()
runtime.goexit /Users/rsc/g/go/src/pkg/runtime/proc.c:150
        runtime.goexit()
----- goroutine created by -----
_rt0_amd64+0x8e /Users/rsc/g/go/src/pkg/runtime/amd64/asm.s:64

Fixes #1563.

R=r
CC=golang-dev
https://golang.org/cl/4243046
2011-03-02 13:42:02 -05:00
Brad Fitzpatrick
9733f96b47 http: initialize request Header for the transport
Fixes #1558

R=rsc, r, bradfitzwork
CC=golang-dev
https://golang.org/cl/4260042
2011-03-02 10:21:56 -08:00
David Symonds
1d258a554a http: give ParseHTTPVersion a real example.
R=rsc
CC=golang-dev
https://golang.org/cl/4239050
2011-03-02 10:10:12 +11:00
Brad Fitzpatrick
60f193781d http: expose Client's Transport
This is again an intentionally minimal change.

The plan is to keep Client's zero value be a usable
client, with optional fields being added over time
(e.g. cookie manager, redirect policy, auth)

R=rsc
CC=golang-dev
https://golang.org/cl/4239044
2011-03-01 14:07:28 -08:00
Rob Pike
a77744f488 fmt: delete debugging print that crept in to test.
(you'd never see it, but ouch.)
Spotted by Florian Weimer.

R=rsc
CC=golang-dev
https://golang.org/cl/4259044
2011-03-01 13:39:44 -08:00
Rob Pike
2b9ab22732 fmt: make %#p suppress leading 0x
Fixes bug 1567.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4245048
2011-03-01 13:25:52 -08:00
David Symonds
7eaecb8915 http: export parseHTTPVersion.
R=rsc, adg
CC=golang-dev
https://golang.org/cl/4244045
2011-03-01 22:38:18 +11:00
Chris Dollin
b00f7310f3 xml: permit nested directives
Return <!DOCTYPE ...> with nested directives as one big token.

Fixes #1549.

R=niemeyer, rsc
CC=golang-dev
https://golang.org/cl/4216050
2011-02-28 14:09:04 -05:00
Rob Pike
b2efedbf36 template: document the delimiters better
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4248047
2011-02-28 10:27:33 -08:00
Mikio Hara
dd51f3537f syscall: regenerate zerrors_freebsd_amd64.go
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4248043
2011-02-28 10:21:19 -05:00
Russ Cox
582fd17e11 runtime: idle goroutine
This functionality might be used in environments
where programs are limited to a single thread,
to simulate a select-driven network server.  It is
not exposed via the standard runtime API.

R=r, r2
CC=golang-dev
https://golang.org/cl/4254041
2011-02-27 23:32:42 -05:00
Nigel Tao
fdbbb066ed compress/lzw: don't use a closure in NewReader, which avoids having
to move some variables from the stack to the heap.

Sorted benchmark runs on my 2007-era Mac Mini (GOARCH=amd64, GOOS=linux):

Before:
lzw.BenchmarkDecoder        2000        878176 ns/op
lzw.BenchmarkDecoder        2000        878415 ns/op
lzw.BenchmarkDecoder        2000        880352 ns/op
lzw.BenchmarkDecoder        2000        898445 ns/op
lzw.BenchmarkDecoder        2000        901728 ns/op

After:
lzw.BenchmarkDecoder        2000        859065 ns/op
lzw.BenchmarkDecoder        2000        859402 ns/op
lzw.BenchmarkDecoder        2000        860035 ns/op
lzw.BenchmarkDecoder        2000        860555 ns/op
lzw.BenchmarkDecoder        2000        861109 ns/op

The ratio of before/after median times is 1.024.

The runtime.MemStats.Mallocs delta per loop drops from 109 to 104.

R=r, r2, dfc
CC=golang-dev
https://golang.org/cl/4253043
2011-02-26 16:42:49 +11:00