@@ -4,13 +4,14 @@ import (
44 "bufio"
55 "bytes"
66 "fmt"
7- "github.com/hahwul/dalfox/v2/pkg/har"
87 "html/template"
98 "net/http"
109 "net/url"
1110 "os"
1211 "strings"
1312
13+ "github.com/hahwul/dalfox/v2/pkg/har"
14+
1415 "github.com/hahwul/dalfox/v2/pkg/model"
1516)
1617
@@ -19,30 +20,30 @@ func GenerateNewRequest(url, body string, options model.Options) *http.Request {
1920 req , _ := http .NewRequest ("GET" , url , nil )
2021 req = har .AddMessageIDToRequest (req )
2122 // Add the Accept header like browsers do.
22- req .Header .Add ("Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" )
23+ req .Header .Set ("Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" )
2324
2425 if options .Data != "" {
2526 d := []byte (body )
2627 req , _ = http .NewRequest ("POST" , url , bytes .NewBuffer (d ))
2728 req = har .AddMessageIDToRequest (req )
28- req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
29+ req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
2930 }
3031
3132 if len (options .Header ) > 0 {
3233 for _ , v := range options .Header {
3334 h := strings .Split (v , ": " )
3435 if len (h ) > 1 {
35- req .Header .Add (h [0 ], h [1 ])
36+ req .Header .Set (h [0 ], h [1 ])
3637 }
3738 }
3839 }
3940 if options .Cookie != "" {
40- req .Header .Add ("Cookie" , options .Cookie )
41+ req .Header .Set ("Cookie" , options .Cookie )
4142 }
4243 if options .UserAgent != "" {
43- req .Header .Add ("User-Agent" , options .UserAgent )
44+ req .Header .Set ("User-Agent" , options .UserAgent )
4445 } else {
45- req .Header .Add ("User-Agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0" )
46+ req .Header .Set ("User-Agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0" )
4647 }
4748 if options .Method != "" {
4849 req .Method = options .Method
@@ -60,7 +61,7 @@ func GenerateNewRequest(url, body string, options model.Options) *http.Request {
6061 fmt .Println (err )
6162 os .Exit (1 )
6263 } else {
63- req .Header .Add ("Cookie" , GetRawCookie (rq .Cookies ()))
64+ req .Header .Set ("Cookie" , GetRawCookie (rq .Cookies ()))
6465 }
6566 }
6667 }
@@ -89,30 +90,30 @@ func MakeHeaderQuery(target, hn, hv string, options model.Options) (*http.Reques
8990 d := []byte ("" )
9091 req , _ = http .NewRequest ("POST" , target , bytes .NewBuffer (d ))
9192 req = har .AddMessageIDToRequest (req )
92- req .Header .Add ("Content-Type" , "application/x-www-form-urlencoded" )
93+ req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
9394 }
9495
9596 if len (options .Header ) > 0 {
9697 for _ , v := range options .Header {
9798 h := strings .Split (v , ": " )
9899 if len (h ) > 1 {
99- req .Header .Add (h [0 ], h [1 ])
100+ req .Header .Set (h [0 ], h [1 ])
100101 }
101102 }
102103 }
103104
104105 if options .Cookie != "" {
105- req .Header .Add ("Cookie" , options .Cookie )
106+ req .Header .Set ("Cookie" , options .Cookie )
106107 }
107108 if options .UserAgent != "" {
108- req .Header .Add ("User-Agent" , options .UserAgent )
109+ req .Header .Set ("User-Agent" , options .UserAgent )
109110 } else {
110- req .Header .Add ("User-Agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0" )
111+ req .Header .Set ("User-Agent" , "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:75.0) Gecko/20100101 Firefox/75.0" )
111112 }
112113 if options .Method != "" {
113114 req .Method = options .Method
114115 }
115- req .Header .Add (hn , hv )
116+ req .Header .Set (hn , hv )
116117 return req , tempMap
117118}
118119
0 commit comments