|
|
@ -31,14 +31,12 @@ func NewDumper(file string, level int) *Dumper {
|
|
|
|
return &Dumper{Out: out, level: level}
|
|
|
|
return &Dumper{Out: out, level: level}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
// call when <-f.Done()
|
|
|
|
log := log.WithField("in", "Dumper")
|
|
|
|
func (d *Dumper) dump(f *flow.Flow) {
|
|
|
|
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
<-f.Done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 参考 httputil.DumpRequest
|
|
|
|
// 参考 httputil.DumpRequest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log := log.WithField("in", "Dumper")
|
|
|
|
|
|
|
|
|
|
|
|
buf := bytes.NewBuffer(make([]byte, 0))
|
|
|
|
buf := bytes.NewBuffer(make([]byte, 0))
|
|
|
|
fmt.Fprintf(buf, "%s %s %s\r\n", f.Request.Method, f.Request.URL.RequestURI(), f.Request.Proto)
|
|
|
|
fmt.Fprintf(buf, "%s %s %s\r\n", f.Request.Method, f.Request.URL.RequestURI(), f.Request.Proto)
|
|
|
|
fmt.Fprintf(buf, "Host: %s\r\n", f.Request.URL.Host)
|
|
|
|
fmt.Fprintf(buf, "Host: %s\r\n", f.Request.URL.Host)
|
|
|
@ -83,6 +81,12 @@ func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
log.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
<-f.Done()
|
|
|
|
|
|
|
|
d.dump(f)
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|