Skip to content

Commit

Permalink
trimspace for body
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Feb 17, 2023
1 parent bd4db1d commit 0b7f837
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mockhttp/mock_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (m *httpHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
}()

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

key=fmt.Sprintf("#%v_#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint, req.Body)
key=fmt.Sprintf("#%v_#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint, strings.TrimSpace(req.Body))
}
//key := fmt.Sprintf("#%v_#%v_#%v", req.Host, strings.ToUpper(req.Method), req.Endpoint)
m.reqMap[key] = rsp
Expand Down

0 comments on commit 0b7f837

Please sign in to comment.