diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-12-03 02:17:34 +0000 |
commit | 2fd401c8f190f1fe43e51a7f726f6ed6119a1f96 (patch) | |
tree | 7f76eff391f37fe6467ff4ffbc0c582c9959ea30 /libgo/go/exp/spdy | |
parent | 02e9018f1616b23f1276151797216717b3564202 (diff) | |
download | gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.zip gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.gz gcc-2fd401c8f190f1fe43e51a7f726f6ed6119a1f96.tar.bz2 |
libgo: Update to weekly.2011-11-02.
From-SVN: r181964
Diffstat (limited to 'libgo/go/exp/spdy')
-rw-r--r-- | libgo/go/exp/spdy/read.go | 49 | ||||
-rw-r--r-- | libgo/go/exp/spdy/types.go | 9 | ||||
-rw-r--r-- | libgo/go/exp/spdy/write.go | 33 |
3 files changed, 44 insertions, 47 deletions
diff --git a/libgo/go/exp/spdy/read.go b/libgo/go/exp/spdy/read.go index 2b1fd3d..3de80c0 100644 --- a/libgo/go/exp/spdy/read.go +++ b/libgo/go/exp/spdy/read.go @@ -9,19 +9,18 @@ import ( "encoding/binary" "http" "io" - "os" "strings" ) -func (frame *SynStreamFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *SynStreamFrame) read(h ControlFrameHeader, f *Framer) error { return f.readSynStreamFrame(h, frame) } -func (frame *SynReplyFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *SynReplyFrame) read(h ControlFrameHeader, f *Framer) error { return f.readSynReplyFrame(h, frame) } -func (frame *RstStreamFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *RstStreamFrame) read(h ControlFrameHeader, f *Framer) error { frame.CFHeader = h if err := binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil { return err @@ -32,7 +31,7 @@ func (frame *RstStreamFrame) read(h ControlFrameHeader, f *Framer) os.Error { return nil } -func (frame *SettingsFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *SettingsFrame) read(h ControlFrameHeader, f *Framer) error { frame.CFHeader = h var numSettings uint32 if err := binary.Read(f.r, binary.BigEndian, &numSettings); err != nil { @@ -52,12 +51,12 @@ func (frame *SettingsFrame) read(h ControlFrameHeader, f *Framer) os.Error { return nil } -func (frame *NoopFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *NoopFrame) read(h ControlFrameHeader, f *Framer) error { frame.CFHeader = h return nil } -func (frame *PingFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *PingFrame) read(h ControlFrameHeader, f *Framer) error { frame.CFHeader = h if err := binary.Read(f.r, binary.BigEndian, &frame.Id); err != nil { return err @@ -65,7 +64,7 @@ func (frame *PingFrame) read(h ControlFrameHeader, f *Framer) os.Error { return nil } -func (frame *GoAwayFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *GoAwayFrame) read(h ControlFrameHeader, f *Framer) error { frame.CFHeader = h if err := binary.Read(f.r, binary.BigEndian, &frame.LastGoodStreamId); err != nil { return err @@ -73,11 +72,11 @@ func (frame *GoAwayFrame) read(h ControlFrameHeader, f *Framer) os.Error { return nil } -func (frame *HeadersFrame) read(h ControlFrameHeader, f *Framer) os.Error { +func (frame *HeadersFrame) read(h ControlFrameHeader, f *Framer) error { return f.readHeadersFrame(h, frame) } -func newControlFrame(frameType ControlFrameType) (controlFrame, os.Error) { +func newControlFrame(frameType ControlFrameType) (controlFrame, error) { ctor, ok := cframeCtor[frameType] if !ok { return nil, &Error{Err: InvalidControlFrame} @@ -97,7 +96,7 @@ var cframeCtor = map[ControlFrameType]func() controlFrame{ // TODO(willchan): Add TypeWindowUpdate } -func (f *Framer) uncorkHeaderDecompressor(payloadSize int64) os.Error { +func (f *Framer) uncorkHeaderDecompressor(payloadSize int64) error { if f.headerDecompressor != nil { f.headerReader.N = payloadSize return nil @@ -112,7 +111,7 @@ func (f *Framer) uncorkHeaderDecompressor(payloadSize int64) os.Error { } // ReadFrame reads SPDY encoded data and returns a decompressed Frame. -func (f *Framer) ReadFrame() (Frame, os.Error) { +func (f *Framer) ReadFrame() (Frame, error) { var firstWord uint32 if err := binary.Read(f.r, binary.BigEndian, &firstWord); err != nil { return nil, err @@ -125,7 +124,7 @@ func (f *Framer) ReadFrame() (Frame, os.Error) { return f.parseDataFrame(firstWord & 0x7fffffff) } -func (f *Framer) parseControlFrame(version uint16, frameType ControlFrameType) (Frame, os.Error) { +func (f *Framer) parseControlFrame(version uint16, frameType ControlFrameType) (Frame, error) { var length uint32 if err := binary.Read(f.r, binary.BigEndian, &length); err != nil { return nil, err @@ -143,12 +142,12 @@ func (f *Framer) parseControlFrame(version uint16, frameType ControlFrameType) ( return cframe, nil } -func parseHeaderValueBlock(r io.Reader, streamId uint32) (http.Header, os.Error) { +func parseHeaderValueBlock(r io.Reader, streamId uint32) (http.Header, error) { var numHeaders uint16 if err := binary.Read(r, binary.BigEndian, &numHeaders); err != nil { return nil, err } - var e os.Error + var e error h := make(http.Header, int(numHeaders)) for i := 0; i < int(numHeaders); i++ { var length uint16 @@ -185,9 +184,9 @@ func parseHeaderValueBlock(r io.Reader, streamId uint32) (http.Header, os.Error) return h, nil } -func (f *Framer) readSynStreamFrame(h ControlFrameHeader, frame *SynStreamFrame) os.Error { +func (f *Framer) readSynStreamFrame(h ControlFrameHeader, frame *SynStreamFrame) error { frame.CFHeader = h - var err os.Error + var err error if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil { return err } @@ -206,7 +205,7 @@ func (f *Framer) readSynStreamFrame(h ControlFrameHeader, frame *SynStreamFrame) } frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId) - if !f.headerCompressionDisabled && ((err == os.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { + if !f.headerCompressionDisabled && ((err == io.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { err = &Error{WrongCompressedPayloadSize, 0} } if err != nil { @@ -223,9 +222,9 @@ func (f *Framer) readSynStreamFrame(h ControlFrameHeader, frame *SynStreamFrame) return nil } -func (f *Framer) readSynReplyFrame(h ControlFrameHeader, frame *SynReplyFrame) os.Error { +func (f *Framer) readSynReplyFrame(h ControlFrameHeader, frame *SynReplyFrame) error { frame.CFHeader = h - var err os.Error + var err error if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil { return err } @@ -239,7 +238,7 @@ func (f *Framer) readSynReplyFrame(h ControlFrameHeader, frame *SynReplyFrame) o reader = f.headerDecompressor } frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId) - if !f.headerCompressionDisabled && ((err == os.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { + if !f.headerCompressionDisabled && ((err == io.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { err = &Error{WrongCompressedPayloadSize, 0} } if err != nil { @@ -256,9 +255,9 @@ func (f *Framer) readSynReplyFrame(h ControlFrameHeader, frame *SynReplyFrame) o return nil } -func (f *Framer) readHeadersFrame(h ControlFrameHeader, frame *HeadersFrame) os.Error { +func (f *Framer) readHeadersFrame(h ControlFrameHeader, frame *HeadersFrame) error { frame.CFHeader = h - var err os.Error + var err error if err = binary.Read(f.r, binary.BigEndian, &frame.StreamId); err != nil { return err } @@ -272,7 +271,7 @@ func (f *Framer) readHeadersFrame(h ControlFrameHeader, frame *HeadersFrame) os. reader = f.headerDecompressor } frame.Headers, err = parseHeaderValueBlock(reader, frame.StreamId) - if !f.headerCompressionDisabled && ((err == os.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { + if !f.headerCompressionDisabled && ((err == io.EOF && f.headerReader.N == 0) || f.headerReader.N != 0) { err = &Error{WrongCompressedPayloadSize, 0} } if err != nil { @@ -296,7 +295,7 @@ func (f *Framer) readHeadersFrame(h ControlFrameHeader, frame *HeadersFrame) os. return nil } -func (f *Framer) parseDataFrame(streamId uint32) (*DataFrame, os.Error) { +func (f *Framer) parseDataFrame(streamId uint32) (*DataFrame, error) { var length uint32 if err := binary.Read(f.r, binary.BigEndian, &length); err != nil { return nil, err diff --git a/libgo/go/exp/spdy/types.go b/libgo/go/exp/spdy/types.go index 41cafb1..87d6edb 100644 --- a/libgo/go/exp/spdy/types.go +++ b/libgo/go/exp/spdy/types.go @@ -9,7 +9,6 @@ import ( "compress/zlib" "http" "io" - "os" ) // Data Frame Format @@ -161,7 +160,7 @@ const MaxDataLength = 1<<24 - 1 // Frame is a single SPDY frame in its unpacked in-memory representation. Use // Framer to read and write it. type Frame interface { - write(f *Framer) os.Error + write(f *Framer) error } // ControlFrameHeader contains all the fields in a control frame header, @@ -176,7 +175,7 @@ type ControlFrameHeader struct { type controlFrame interface { Frame - read(h ControlFrameHeader, f *Framer) os.Error + read(h ControlFrameHeader, f *Framer) error } // SynStreamFrame is the unpacked, in-memory representation of a SYN_STREAM @@ -321,7 +320,7 @@ type Error struct { StreamId uint32 } -func (e *Error) String() string { +func (e *Error) Error() string { return string(e.Err) } @@ -354,7 +353,7 @@ type Framer struct { // a io.Writer and io.Reader. Note that Framer will read and write individual fields // from/to the Reader and Writer, so the caller should pass in an appropriately // buffered implementation to optimize performance. -func NewFramer(w io.Writer, r io.Reader) (*Framer, os.Error) { +func NewFramer(w io.Writer, r io.Reader) (*Framer, error) { compressBuf := new(bytes.Buffer) compressor, err := zlib.NewWriterDict(compressBuf, zlib.BestCompression, []byte(HeaderDictionary)) if err != nil { diff --git a/libgo/go/exp/spdy/write.go b/libgo/go/exp/spdy/write.go index 7d40bbe..537154f 100644 --- a/libgo/go/exp/spdy/write.go +++ b/libgo/go/exp/spdy/write.go @@ -8,19 +8,18 @@ import ( "encoding/binary" "http" "io" - "os" "strings" ) -func (frame *SynStreamFrame) write(f *Framer) os.Error { +func (frame *SynStreamFrame) write(f *Framer) error { return f.writeSynStreamFrame(frame) } -func (frame *SynReplyFrame) write(f *Framer) os.Error { +func (frame *SynReplyFrame) write(f *Framer) error { return f.writeSynReplyFrame(frame) } -func (frame *RstStreamFrame) write(f *Framer) (err os.Error) { +func (frame *RstStreamFrame) write(f *Framer) (err error) { frame.CFHeader.version = Version frame.CFHeader.frameType = TypeRstStream frame.CFHeader.length = 8 @@ -38,7 +37,7 @@ func (frame *RstStreamFrame) write(f *Framer) (err os.Error) { return } -func (frame *SettingsFrame) write(f *Framer) (err os.Error) { +func (frame *SettingsFrame) write(f *Framer) (err error) { frame.CFHeader.version = Version frame.CFHeader.frameType = TypeSettings frame.CFHeader.length = uint32(len(frame.FlagIdValues)*8 + 4) @@ -62,7 +61,7 @@ func (frame *SettingsFrame) write(f *Framer) (err os.Error) { return } -func (frame *NoopFrame) write(f *Framer) os.Error { +func (frame *NoopFrame) write(f *Framer) error { frame.CFHeader.version = Version frame.CFHeader.frameType = TypeNoop @@ -70,7 +69,7 @@ func (frame *NoopFrame) write(f *Framer) os.Error { return writeControlFrameHeader(f.w, frame.CFHeader) } -func (frame *PingFrame) write(f *Framer) (err os.Error) { +func (frame *PingFrame) write(f *Framer) (err error) { frame.CFHeader.version = Version frame.CFHeader.frameType = TypePing frame.CFHeader.length = 4 @@ -85,7 +84,7 @@ func (frame *PingFrame) write(f *Framer) (err os.Error) { return } -func (frame *GoAwayFrame) write(f *Framer) (err os.Error) { +func (frame *GoAwayFrame) write(f *Framer) (err error) { frame.CFHeader.version = Version frame.CFHeader.frameType = TypeGoAway frame.CFHeader.length = 4 @@ -100,20 +99,20 @@ func (frame *GoAwayFrame) write(f *Framer) (err os.Error) { return nil } -func (frame *HeadersFrame) write(f *Framer) os.Error { +func (frame *HeadersFrame) write(f *Framer) error { return f.writeHeadersFrame(frame) } -func (frame *DataFrame) write(f *Framer) os.Error { +func (frame *DataFrame) write(f *Framer) error { return f.writeDataFrame(frame) } // WriteFrame writes a frame. -func (f *Framer) WriteFrame(frame Frame) os.Error { +func (f *Framer) WriteFrame(frame Frame) error { return frame.write(f) } -func writeControlFrameHeader(w io.Writer, h ControlFrameHeader) os.Error { +func writeControlFrameHeader(w io.Writer, h ControlFrameHeader) error { if err := binary.Write(w, binary.BigEndian, 0x8000|h.version); err != nil { return err } @@ -127,7 +126,7 @@ func writeControlFrameHeader(w io.Writer, h ControlFrameHeader) os.Error { return nil } -func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err os.Error) { +func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err error) { n = 0 if err = binary.Write(w, binary.BigEndian, uint16(len(h))); err != nil { return @@ -156,7 +155,7 @@ func writeHeaderValueBlock(w io.Writer, h http.Header) (n int, err os.Error) { return } -func (f *Framer) writeSynStreamFrame(frame *SynStreamFrame) (err os.Error) { +func (f *Framer) writeSynStreamFrame(frame *SynStreamFrame) (err error) { // Marshal the headers. var writer io.Writer = f.headerBuf if !f.headerCompressionDisabled { @@ -194,7 +193,7 @@ func (f *Framer) writeSynStreamFrame(frame *SynStreamFrame) (err os.Error) { return nil } -func (f *Framer) writeSynReplyFrame(frame *SynReplyFrame) (err os.Error) { +func (f *Framer) writeSynReplyFrame(frame *SynReplyFrame) (err error) { // Marshal the headers. var writer io.Writer = f.headerBuf if !f.headerCompressionDisabled { @@ -229,7 +228,7 @@ func (f *Framer) writeSynReplyFrame(frame *SynReplyFrame) (err os.Error) { return } -func (f *Framer) writeHeadersFrame(frame *HeadersFrame) (err os.Error) { +func (f *Framer) writeHeadersFrame(frame *HeadersFrame) (err error) { // Marshal the headers. var writer io.Writer = f.headerBuf if !f.headerCompressionDisabled { @@ -264,7 +263,7 @@ func (f *Framer) writeHeadersFrame(frame *HeadersFrame) (err os.Error) { return } -func (f *Framer) writeDataFrame(frame *DataFrame) (err os.Error) { +func (f *Framer) writeDataFrame(frame *DataFrame) (err error) { // Validate DataFrame if frame.StreamId&0x80000000 != 0 || len(frame.Data) >= 0x0f000000 { return &Error{InvalidDataFrame, frame.StreamId} |