Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix build after recent library changes

  • Loading branch information...
commit d000339d547046e7f346d320adbabb78cee943c1 1 parent 5c3d513
@edsrzf authored
Showing with 23 additions and 15 deletions.
  1. +18 −10 application.go
  2. +2 −2 exec.go
  3. +3 −3 handler.go
View
28 application.go
@@ -10,6 +10,7 @@ package fcgi
import (
"bytes"
"encoding/binary"
+ "fmt"
"http"
"io"
"log"
@@ -153,7 +154,7 @@ type response struct {
// the ReadWriteCloser to do real I/O on
conn *lockReadWriteCloser
// reply header parameters
- header map[string]string
+ header http.Header
// the buffer that Write writes to
buf bytes.Buffer
// reply header has been written
@@ -172,10 +173,10 @@ func newResponse(rwc *lockReadWriteCloser, req *request) *response {
r := new(response)
r.conn = rwc
r.req = req
- r.header = make(map[string]string)
+ r.header = make(http.Header)
- r.SetHeader("Content-Type", "text/html; charset=utf-8")
- r.SetHeader("Date", time.UTC().Format(http.TimeFormat))
+ r.header.Set("Content-Type", "text/html; charset=utf-8")
+ r.header.Set("Date", time.UTC().Format(http.TimeFormat))
return r
}
@@ -191,8 +192,8 @@ func (r *response) UsingTLS() bool {
return false
}
-func (r *response) SetHeader(hdr, val string) {
- r.header[http.CanonicalHeaderKey(hdr)] = val
+func (r *response) Header() http.Header {
+ return r.header
}
func (r *response) Write(data []byte) (int, os.Error) {
@@ -210,14 +211,21 @@ func (r *response) WriteHeader(code int) {
r.code = code
if code == http.StatusNotModified {
// must not have body
- r.header["Content-Type"] = "", false
- r.header["Transfer-Encoding"] = "", false
+ r.header.Del("Content-Type")
+ r.header.Del("Content-Length")
+ r.header.Del("Transfer-Encoding")
}
codestring := strconv.Itoa(code)
statusText := http.StatusText(code)
io.WriteString(&r.buf, "Status: "+codestring+" "+statusText+"\r\n")
- for k, v := range r.header {
- io.WriteString(&r.buf, k+": "+v+"\r\n")
+ // TODO: this code is duplicated in http and http/cgi
+ for k, vv := range r.header {
+ for _, v := range vv {
+ v = strings.Replace(v, "\n", "", -1)
+ v = strings.Replace(v, "\r", "", -1)
+ v = strings.TrimSpace(v)
+ fmt.Fprintf(&r.buf, "%s: %s\r\n", k, v)
+ }
}
io.WriteString(&r.buf, "\r\n")
}
View
4 exec.go
@@ -12,7 +12,7 @@ import (
// stdin
func dialExec(binpath string) (io.ReadWriteCloser, os.Error) {
listenBacklog := 1024
- dir, file := path.Split(binpath)
+ _, file := path.Split(binpath)
socketPath := "/tmp/" + file + ".sock"
// if the first socket is really in use (we are launching this same process more
// than once) then the socketIndex will start incrementing so we assign .sock-1
@@ -60,7 +60,7 @@ func dialExec(binpath string) (io.ReadWriteCloser, os.Error) {
// DEBUG: for now, give the new process our stdout, and stderr, but the spec
// says these should be closed
// in reality, we should redirect, capture, and possibly log separately
- if _, errno = syscall.ForkExec(file, []string{}, []string{}, dir, []int{fd, 1, 2}); errno != 0 {
+ if _, errno = syscall.ForkExec(file, []string{}, nil); errno != 0 {
msg := "ForkExec failed: " + syscall.Errstr(errno)
Log(msg)
return nil, os.NewError(msg)
View
6 handler.go
@@ -130,7 +130,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// once response is ready, write it out to the real connection
for k, v := range response.Header {
for _, v := range v {
- w.SetHeader(k, v)
+ w.Header().Set(k, v)
}
}
w.WriteHeader(response.StatusCode)
@@ -287,7 +287,7 @@ func getRequest(reqid uint16, conn http.ResponseWriter, req *http.Request) *requ
// up is separate from whether the browser<->ws connection goes down
// close: req.Close,
params: map[string]string{
- "SERVER_SOFTWARE": "fcgigo-handler",
+ "SERVER_SOFTWARE": "go",
"HTTP_HOST": req.Host,
"SERVER_NAME": req.Host,
"REQUEST_URI": req.RawURL,
@@ -297,7 +297,7 @@ func getRequest(reqid uint16, conn http.ResponseWriter, req *http.Request) *requ
"SERVER_ADDR": "127.0.0.1",
"SERVER_PROTOCOL": req.Proto,
"REMOTE_PORT": "0",
- "REMOTE_ADDR": conn.RemoteAddr(),
+ "REMOTE_ADDR": req.RemoteAddr,
// TODO: this wouldn't be defined for a remote responder, but would
// if it were spawned. deferred until we support dynamic spawning again
// (ie have unit tests).
Please sign in to comment.
Something went wrong with that request. Please try again.