Skip to content

Commit a160b21

Browse files
committed
fix: Always use DataString instead of data
1 parent 8c2e18b commit a160b21

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

pkg/proxy/proxy.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package proxy
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/json"
76
"fmt"
8-
"io"
97
"io/ioutil"
108
"net/http"
119
"net/url"
@@ -197,7 +195,7 @@ func (p *Proxy) processAttempt(msg websocket.IncomingMessage) {
197195
}).Debugf("Processing webhook event")
198196

199197
if p.cfg.PrintJSON {
200-
fmt.Println(webhookEvent.Body.Request.Data)
198+
fmt.Println(webhookEvent.Body.Request.DataString)
201199
} else {
202200
url := "http://localhost:" + p.cfg.Port + webhookEvent.Body.Path
203201

@@ -221,24 +219,12 @@ func (p *Proxy) processAttempt(msg websocket.IncomingMessage) {
221219
return
222220
}
223221

224-
bodyIsText := false
225-
226222
for key, value := range x {
227223
unquoted_value, _ := strconv.Unquote(string(value))
228224
req.Header.Set(key, unquoted_value)
229-
230-
if strings.EqualFold(strings.ToLower(key), strings.ToLower("content-type")) {
231-
if strings.Contains(strings.ToLower(string(value)), strings.ToLower("www-form-urlencoded")) || strings.Contains(strings.ToLower(string(value)), strings.ToLower("text/plain")) {
232-
bodyIsText = true
233-
}
234-
}
235225
}
236226

237-
if bodyIsText {
238-
req.Body = ioutil.NopCloser(strings.NewReader(webhookEvent.Body.Request.DataString))
239-
} else {
240-
req.Body = io.NopCloser(bytes.NewBuffer(webhookEvent.Body.Request.Data))
241-
}
227+
req.Body = ioutil.NopCloser(strings.NewReader(webhookEvent.Body.Request.DataString))
242228

243229
res, err := client.Do(req)
244230
if err != nil {

pkg/websocket/attempt_messages.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ import (
55
)
66

77
type AttemptRequest struct {
8-
Method string `json:"method"`
9-
Timeout int64 `json:"timeout"`
10-
Data json.RawMessage `json:"data"`
11-
DataString string `json:"data_string"`
12-
Headers json.RawMessage `json:"headers"`
8+
Method string `json:"method"`
9+
Timeout int64 `json:"timeout"`
10+
DataString string `json:"data_string"`
11+
Headers json.RawMessage `json:"headers"`
1312
}
1413

1514
type AttemptBody struct {

0 commit comments

Comments
 (0)