mirror of
https://github.com/mmatczuk/go-http-tunnel.git
synced 2026-05-15 14:16:17 -06:00
server: http log sent bytes
This commit is contained in:
parent
1bbcb98198
commit
7849170e92
2 changed files with 14 additions and 1 deletions
|
|
@ -252,8 +252,10 @@ func (s *Server) proxy(host string, w io.Writer, r interface{}, msg *proto.Contr
|
|||
|
||||
localToRemote := func() {
|
||||
if hr, ok := r.(*http.Request); ok {
|
||||
hr.Write(pw)
|
||||
cw := &countWriter{pw, 0}
|
||||
hr.Write(cw)
|
||||
pw.Close()
|
||||
s.log.Debug("Coppied %d bytes from %s", cw.count, "local to remote")
|
||||
} else {
|
||||
transfer("local to remote", pw, r.(io.ReadCloser), s.log)
|
||||
}
|
||||
|
|
|
|||
11
utils.go
11
utils.go
|
|
@ -46,6 +46,17 @@ func copyHeader(dst, src http.Header) {
|
|||
}
|
||||
}
|
||||
|
||||
type countWriter struct {
|
||||
w io.Writer
|
||||
count int64
|
||||
}
|
||||
|
||||
func (cw *countWriter) Write(p []byte) (n int, err error) {
|
||||
n, err = cw.w.Write(p)
|
||||
cw.count += int64(n)
|
||||
return
|
||||
}
|
||||
|
||||
type flushWriter struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue