~hduran-8/+junk/caddy

« back to all changes in this revision

Viewing changes to debian/gocode/src/golang.org/x/net/http2/http2.go

  • Committer: Horacio Durán
  • Date: 2017-01-20 16:21:20 UTC
  • Revision ID: horacio.duran@canonical.com-20170120162120-l82mfqwmsclnk838
Upgrade to 0.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        VerboseLogs    bool
37
37
        logFrameWrites bool
38
38
        logFrameReads  bool
 
39
        inTests        bool
39
40
)
40
41
 
41
42
func init() {
77
78
 
78
79
type streamState int
79
80
 
 
81
// HTTP/2 stream states.
 
82
//
 
83
// See http://tools.ietf.org/html/rfc7540#section-5.1.
 
84
//
 
85
// For simplicity, the server code merges "reserved (local)" into
 
86
// "half-closed (remote)". This is one less state transition to track.
 
87
// The only downside is that we send PUSH_PROMISEs slightly less
 
88
// liberally than allowable. More discussion here:
 
89
// https://lists.w3.org/Archives/Public/ietf-http-wg/2016JulSep/0599.html
 
90
//
 
91
// "reserved (remote)" is omitted since the client code does not
 
92
// support server push.
80
93
const (
81
94
        stateIdle streamState = iota
82
95
        stateOpen
83
96
        stateHalfClosedLocal
84
97
        stateHalfClosedRemote
85
 
        stateResvLocal
86
 
        stateResvRemote
87
98
        stateClosed
88
99
)
89
100
 
92
103
        stateOpen:             "Open",
93
104
        stateHalfClosedLocal:  "HalfClosedLocal",
94
105
        stateHalfClosedRemote: "HalfClosedRemote",
95
 
        stateResvLocal:        "ResvLocal",
96
 
        stateResvRemote:       "ResvRemote",
97
106
        stateClosed:           "Closed",
98
107
}
99
108
 
253
262
        return &bufferedWriter{w: w}
254
263
}
255
264
 
 
265
// bufWriterPoolBufferSize is the size of bufio.Writer's
 
266
// buffers created using bufWriterPool.
 
267
//
 
268
// TODO: pick a less arbitrary value? this is a bit under
 
269
// (3 x typical 1500 byte MTU) at least. Other than that,
 
270
// not much thought went into it.
 
271
const bufWriterPoolBufferSize = 4 << 10
 
272
 
256
273
var bufWriterPool = sync.Pool{
257
274
        New: func() interface{} {
258
 
                // TODO: pick something better? this is a bit under
259
 
                // (3 x typical 1500 byte MTU) at least.
260
 
                return bufio.NewWriterSize(nil, 4<<10)
 
275
                return bufio.NewWriterSize(nil, bufWriterPoolBufferSize)
261
276
        },
262
277
}
263
278
 
 
279
func (w *bufferedWriter) Available() int {
 
280
        if w.bw == nil {
 
281
                return bufWriterPoolBufferSize
 
282
        }
 
283
        return w.bw.Available()
 
284
}
 
285
 
264
286
func (w *bufferedWriter) Write(p []byte) (n int, err error) {
265
287
        if w.bw == nil {
266
288
                bw := bufWriterPool.Get().(*bufio.Writer)