Open nxk88998 opened 8 months ago
已修复,添加charset=utf-8到Content-Type标头显式指定字符编码修复
func (r *Requester) PostXML(ctx context.Context, endpoint string, xml string, responseStruct interface{}, querystring map[string]string) (*http.Response, error) { payload := bytes.NewBuffer([]byte(xml)) ar := NewAPIRequest("POST", endpoint, payload) if err := r.SetCrumb(ctx, ar); err != nil { return nil, err } ar.SetHeader("Content-Type", "application/xml; charset=utf-8") ar.Suffix = "" return r.Do(ctx, ar, &responseStruct, querystring) }
如何解决的
如何解决的
request.go文件中修改PostXML函数添加默认charset=utf-8
完整代码 func (r Requester) PostXML(ctx context.Context, endpoint string, xml string, responseStruct interface{}, querystring map[string]string) (http.Response, error) { payload := bytes.NewBuffer([]byte(xml)) ar := NewAPIRequest("POST", endpoint, payload) if err := r.SetCrumb(ctx, ar); err != nil { return nil, err } ar.SetHeader("Content-Type", "application/xml; charset=utf-8") ar.Suffix = "" return r.Do(ctx, ar, &responseStruct, querystring) }
测试 >> Jenkins displays garbled code >> æµè¯