karldoenitz/Tigo

DumpHttpRequestMsg函数打印http body异常

Closed this issue · 1 comments

问题描述

使用DumpHttpRequestMsg,打印http请求报文,报文数据异常,有时候报错,有时候http报文体内会有url上的参数。


复现方式

http请求采用post方式,Content-Type: application/x-www-form-urlencoded,然后url上再携带上参数,case如下所示:

### 测试http dump
POST http://localhost:8080/fast?k=v
Content-Type: application/x-www-form-urlencoded; charset=utf-8

k1=v1&k2=v2&k3=v3

运行测试用例,打印结果:

POST /fast?k=v HTTP/1.1
Host: localhost:8080
Content-Type: application/x-www-form-urlencoded; charset=utf-8

k1=v1&k2=v2&k3=v3&k=v

原因:

bodyData := getFormDataStr(baseHandler.Request.Form)

baseHandler.Request.Form改为baseHandler.Request.PostForm