Skip to content

Commit 00816d0

Browse files
fix request size calculation (#132)
1 parent cae8402 commit 00816d0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

http-tracer.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ func (r *recordRequest) Read(p []byte) (n int, err error) {
6767

6868
func (r *recordRequest) Size() int {
6969
sz := r.bytesRead
70-
for k, v := range r.headers {
71-
sz += len(k) + len(v)
70+
for k, vals := range r.headers {
71+
for _, v := range vals {
72+
sz += len(k) + len(v)
73+
}
7274
}
7375
return sz
7476
}
@@ -92,7 +94,7 @@ type ResponseWriter struct {
9294
}
9395

9496
// NewResponseWriter - returns a wrapped response writer to trap
95-
// http status codes for auditiing purposes.
97+
// HTTP status codes for auditing purposes.
9698
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter {
9799
return &ResponseWriter{
98100
ResponseWriter: w,
@@ -162,7 +164,7 @@ func (lrw *ResponseWriter) Flush() {
162164
lrw.ResponseWriter.(http.Flusher).Flush()
163165
}
164166

165-
// Size - reutrns the number of bytes written
167+
// Size - returns the number of bytes written
166168
func (lrw *ResponseWriter) Size() int {
167169
return lrw.bytesWritten
168170
}

write_on_close.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (w *WriteOnCloser) Close() error {
5050
// HasWritten returns true if at least one write operation was performed.
5151
func (w *WriteOnCloser) HasWritten() bool { return w.hasWritten }
5252

53-
// WriteOnClose takes an io.Writer and returns an ioutil.WriteOnCloser.
53+
// WriteOnClose takes an io.Writer and returns a WriteOnCloser.
5454
func WriteOnClose(w io.Writer) *WriteOnCloser {
5555
return &WriteOnCloser{w, false}
5656
}

0 commit comments

Comments
 (0)