Skip to content

Commit 0b7f837

Browse files
committed
trimspace for body
1 parent bd4db1d commit 0b7f837

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mockhttp/mock_http.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (m *httpHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
191191
}()
192192

193193
key := fmt.Sprintf("#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.URL.Path)
194-
reqBody := m.getRequestBody(req)
194+
reqBody := strings.TrimSpace( m.getRequestBody(req))
195195
if reqBody != "" {
196196
key = fmt.Sprintf("#%v_#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.URL.Path, reqBody)
197197
if _, ok := m.mockHttpServer.reqMap[key]; !ok {
@@ -362,7 +362,7 @@ func (m *MockHttpServer) setReqToResponse(req Request, rsp Response) {
362362
key := fmt.Sprintf("#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint)
363363
if req.Body != "" {
364364

365-
key=fmt.Sprintf("#%v_#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint, req.Body)
365+
key=fmt.Sprintf("#%v_#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint, strings.TrimSpace(req.Body))
366366
}
367367
//key := fmt.Sprintf("#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint)
368368
m.reqMap[key] = rsp

0 commit comments

Comments
 (0)