@@ -5,12 +5,14 @@ import (
55 "context"
66 "encoding/json"
77 "fmt"
8+ "io"
89 "io/ioutil"
910 "net/http"
1011 "net/url"
1112 "os"
1213 "os/signal"
1314 "strconv"
15+ "strings"
1416 "syscall"
1517 "time"
1618
@@ -206,7 +208,9 @@ func (p *Proxy) processAttempt(msg websocket.IncomingMessage) {
206208 client := & http.Client {
207209 Timeout : time .Duration (timeout ) * time .Millisecond ,
208210 }
209- req , err := http .NewRequest (webhookEvent .Body .Request .Method , url , bytes .NewBuffer (webhookEvent .Body .Request .Data ))
211+ fmt .Println (bytes .NewBuffer (webhookEvent .Body .Request .Headers ));
212+
213+ req , err := http .NewRequest (webhookEvent .Body .Request .Method , url , nil )
210214 if err != nil {
211215 fmt .Printf ("Error: %s\n " , err )
212216 return
@@ -217,10 +221,26 @@ func (p *Proxy) processAttempt(msg websocket.IncomingMessage) {
217221 fmt .Printf ("Error: %s\n " , err )
218222 return
219223 }
224+
225+ bodyIsText := false
226+
220227 for key , value := range x {
221228 unquoted_value , _ := strconv .Unquote (string (value ))
222229 req .Header .Set (key , unquoted_value )
230+
231+ if (strings .EqualFold (strings .ToLower (key ), strings .ToLower ("content-type" ))) {
232+ if (strings .Contains (strings .ToLower (string (value )), strings .ToLower ("www-form-urlencoded" )) || strings .Contains (strings .ToLower (string (value )), strings .ToLower ("text/plain" ))) {
233+ bodyIsText = true
234+ }
235+ }
223236 }
237+
238+ if bodyIsText {
239+ req .Body = ioutil .NopCloser (strings .NewReader (webhookEvent .Body .Request .DataString ))
240+ } else {
241+ req .Body = io .NopCloser (bytes .NewBuffer (webhookEvent .Body .Request .Data ))
242+ }
243+
224244 res , err := client .Do (req )
225245 if err != nil {
226246 color := ansi .Color (os .Stdout )
0 commit comments