|
|
|
@ -31,14 +31,12 @@ func NewDumper(file string, level int) *Dumper {
|
|
|
|
|
return &Dumper{Out: out, level: level}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
|
log := log.WithField("in", "Dumper")
|
|
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
<-f.Done()
|
|
|
|
|
|
|
|
|
|
// call when <-f.Done()
|
|
|
|
|
func (d *Dumper) dump(f *flow.Flow) {
|
|
|
|
|
// 参考 httputil.DumpRequest
|
|
|
|
|
|
|
|
|
|
log := log.WithField("in", "Dumper")
|
|
|
|
|
|
|
|
|
|
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, "Host: %s\r\n", f.Request.URL.Host)
|
|
|
|
@ -83,6 +81,12 @@ func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (d *Dumper) Requestheaders(f *flow.Flow) {
|
|
|
|
|
go func() {
|
|
|
|
|
<-f.Done()
|
|
|
|
|
d.dump(f)
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|