Merge remote-tracking branch 'remotes/upstream/develop' into err_ctrler

This commit is contained in:
JessonChan
2016-03-09 15:59:13 +08:00
30 changed files with 796 additions and 166 deletions

View File

@@ -24,11 +24,13 @@ package context
import (
"bufio"
"bytes"
"crypto/hmac"
"crypto/sha1"
"encoding/base64"
"errors"
"fmt"
"io"
"net"
"net/http"
"strconv"
@@ -193,6 +195,14 @@ func (w *Response) Write(p []byte) (int, error) {
return w.ResponseWriter.Write(p)
}
// Write writes the data to the connection as part of an HTTP reply,
// and sets `started` to true.
// started means the response has sent out.
func (w *Response) Copy(buf *bytes.Buffer) (int64, error) {
w.Started = true
return io.Copy(w.ResponseWriter, buf)
}
// WriteHeader sends an HTTP response header with status code,
// and sets `started` to true.
func (w *Response) WriteHeader(code int) {