LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package fcgi | 5 package fcgi |
6 | 6 |
7 // This file implements FastCGI from the perspective of a child process. | 7 // This file implements FastCGI from the perspective of a child process. |
8 | 8 |
9 import ( | 9 import ( |
10 "errors" | 10 "errors" |
(...skipping 13 matching lines...) Expand all Loading... |
24 reqId uint16 | 24 reqId uint16 |
25 params map[string]string | 25 params map[string]string |
26 buf [1024]byte | 26 buf [1024]byte |
27 rawParams []byte | 27 rawParams []byte |
28 keepConn bool | 28 keepConn bool |
29 } | 29 } |
30 | 30 |
31 func newRequest(reqId uint16, flags uint8) *request { | 31 func newRequest(reqId uint16, flags uint8) *request { |
32 r := &request{ | 32 r := &request{ |
33 reqId: reqId, | 33 reqId: reqId, |
34 » » params: map[string]string{}, | 34 » » params: {}, |
35 keepConn: flags&flagKeepConn != 0, | 35 keepConn: flags&flagKeepConn != 0, |
36 } | 36 } |
37 r.rawParams = r.buf[:0] | 37 r.rawParams = r.buf[:0] |
38 return r | 38 return r |
39 } | 39 } |
40 | 40 |
41 // parseParams reads an encoded []byte into Params. | 41 // parseParams reads an encoded []byte into Params. |
42 func (r *request) parseParams() { | 42 func (r *request) parseParams() { |
43 text := r.rawParams | 43 text := r.rawParams |
44 r.rawParams = nil | 44 r.rawParams = nil |
(...skipping 20 matching lines...) Expand all Loading... |
65 type response struct { | 65 type response struct { |
66 req *request | 66 req *request |
67 header http.Header | 67 header http.Header |
68 w *bufWriter | 68 w *bufWriter |
69 wroteHeader bool | 69 wroteHeader bool |
70 } | 70 } |
71 | 71 |
72 func newResponse(c *child, req *request) *response { | 72 func newResponse(c *child, req *request) *response { |
73 return &response{ | 73 return &response{ |
74 req: req, | 74 req: req, |
75 » » header: http.Header{}, | 75 » » header: {}, |
76 w: newWriter(c.conn, typeStdout, req.reqId), | 76 w: newWriter(c.conn, typeStdout, req.reqId), |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 func (r *response) Header() http.Header { | 80 func (r *response) Header() http.Header { |
81 return r.header | 81 return r.header |
82 } | 82 } |
83 | 83 |
84 func (r *response) Write(data []byte) (int, error) { | 84 func (r *response) Write(data []byte) (int, error) { |
85 if !r.wroteHeader { | 85 if !r.wroteHeader { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 for { | 262 for { |
263 rw, err := l.Accept() | 263 rw, err := l.Accept() |
264 if err != nil { | 264 if err != nil { |
265 return err | 265 return err |
266 } | 266 } |
267 c := newChild(rw, handler) | 267 c := newChild(rw, handler) |
268 go c.serve() | 268 go c.serve() |
269 } | 269 } |
270 panic("unreachable") | 270 panic("unreachable") |
271 } | 271 } |
LEFT | RIGHT |