OLD | NEW |
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 // This file implements the host side of CGI (being the webserver | 5 // This file implements the host side of CGI (being the webserver |
6 // parent process). | 6 // parent process). |
7 | 7 |
8 // Package cgi implements CGI (Common Gateway Interface) as specified | 8 // Package cgi implements CGI (Common Gateway Interface) as specified |
9 // in RFC 3875. | 9 // in RFC 3875. |
10 // | 10 // |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 269 |
270 func (h *Handler) printf(format string, v ...interface{}) { | 270 func (h *Handler) printf(format string, v ...interface{}) { |
271 if h.Logger != nil { | 271 if h.Logger != nil { |
272 h.Logger.Printf(format, v...) | 272 h.Logger.Printf(format, v...) |
273 } else { | 273 } else { |
274 log.Printf(format, v...) | 274 log.Printf(format, v...) |
275 } | 275 } |
276 } | 276 } |
277 | 277 |
278 func (h *Handler) handleInternalRedirect(rw http.ResponseWriter, req *http.Reque
st, path string) { | 278 func (h *Handler) handleInternalRedirect(rw http.ResponseWriter, req *http.Reque
st, path string) { |
279 » url, err := req.URL.ParseURL(path) | 279 » url, err := req.URL.Parse(path) |
280 if err != nil { | 280 if err != nil { |
281 rw.WriteHeader(http.StatusInternalServerError) | 281 rw.WriteHeader(http.StatusInternalServerError) |
282 h.printf("cgi: error resolving local URI path %q: %v", path, err
) | 282 h.printf("cgi: error resolving local URI path %q: %v", path, err
) |
283 return | 283 return |
284 } | 284 } |
285 // TODO: RFC 3875 isn't clear if only GET is supported, but it | 285 // TODO: RFC 3875 isn't clear if only GET is supported, but it |
286 // suggests so: "Note that any message-body attached to the | 286 // suggests so: "Note that any message-body attached to the |
287 // request (such as for a POST request) may not be available | 287 // request (such as for a POST request) may not be available |
288 // to the resource that is the target of the redirect." We | 288 // to the resource that is the target of the redirect." We |
289 // should do some tests against Apache to see how it handles | 289 // should do some tests against Apache to see how it handles |
(...skipping 24 matching lines...) Expand all Loading... |
314 return '_' | 314 return '_' |
315 case rune == '=': | 315 case rune == '=': |
316 // Maybe not part of the CGI 'spec' but would mess up | 316 // Maybe not part of the CGI 'spec' but would mess up |
317 // the environment in any case, as Go represents the | 317 // the environment in any case, as Go represents the |
318 // environment as a slice of "key=value" strings. | 318 // environment as a slice of "key=value" strings. |
319 return '_' | 319 return '_' |
320 } | 320 } |
321 // TODO: other transformations in spec or practice? | 321 // TODO: other transformations in spec or practice? |
322 return rune | 322 return rune |
323 } | 323 } |
OLD | NEW |