mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-29 20:24:11 +08:00
Merge pull request #429 from abiosoft/php-error-log
fastcgi: separate standard and error output responses.
This commit is contained in:
commit
f11cd4d9dd
|
@ -115,7 +115,13 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
||||||
return http.StatusBadGateway, err
|
return http.StatusBadGateway, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, nil
|
// FastCGI stderr outputs
|
||||||
|
if fcgi.stderr.Len() != 0 {
|
||||||
|
// Remove trailing newline, error logger already does this.
|
||||||
|
err = LogError(strings.TrimSuffix(fcgi.stderr.String(), "\n"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.StatusCode, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,3 +287,11 @@ var (
|
||||||
// ErrIndexMissingSplit describes an index configuration error.
|
// ErrIndexMissingSplit describes an index configuration error.
|
||||||
ErrIndexMissingSplit = errors.New("configured index file(s) must include split value")
|
ErrIndexMissingSplit = errors.New("configured index file(s) must include split value")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LogError is a non fatal error that allows requests to go through.
|
||||||
|
type LogError string
|
||||||
|
|
||||||
|
// Error satisfies error interface.
|
||||||
|
func (l LogError) Error() string {
|
||||||
|
return string(l)
|
||||||
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ type FCGIClient struct {
|
||||||
rwc io.ReadWriteCloser
|
rwc io.ReadWriteCloser
|
||||||
h header
|
h header
|
||||||
buf bytes.Buffer
|
buf bytes.Buffer
|
||||||
|
stderr bytes.Buffer
|
||||||
keepAlive bool
|
keepAlive bool
|
||||||
reqID uint16
|
reqID uint16
|
||||||
}
|
}
|
||||||
|
@ -346,11 +347,23 @@ func (w *streamReader) Read(p []byte) (n int, err error) {
|
||||||
|
|
||||||
if len(p) > 0 {
|
if len(p) > 0 {
|
||||||
if len(w.buf) == 0 {
|
if len(w.buf) == 0 {
|
||||||
|
|
||||||
|
// filter outputs for error log
|
||||||
|
for {
|
||||||
rec := &record{}
|
rec := &record{}
|
||||||
w.buf, err = rec.read(w.c.rwc)
|
var buf []byte
|
||||||
|
buf, err = rec.read(w.c.rwc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// standard error output
|
||||||
|
if rec.h.Type == Stderr {
|
||||||
|
w.c.stderr.Write(buf)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
w.buf = buf
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n = len(p)
|
n = len(p)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user