
使用的 goframe 框架
shared.Common.LogReceiveapi(g.Map{ "url": url, "con": res, "status": "----now start push-----", }, logpath+"/returnData") // 推送地址 //content := g.Client().ContentJson().PostContent(url, res) result, err := g.Client().ContentJson().Post(url, res) if err != nil { thelog := g.Map{ "dump": result.Raw(), "error": err, "status": "----push error-----", } // 记录返回的数据 shared.Common.LogReceiveapi(thelog, logpath+"/returnData") return errors.New("推送失败: " + err.Error()) } defer result.Close() content := result.ReadAllString() thelog := g.Map{ "dump": result.RawDump, "res": content, "status": "----end push-----", } // 记录返回的数据 shared.Common.LogReceiveapi(thelog, logpath+"/returnData") 日志
2023-04-23 11:11:38.785 {"con":{"name":"xxx","list":[{"name":"xx","remark":"xxx","status":""}]},"status":"----now start push-----","url":"http://xxx"} 2023-04-23 11:12:38.802 {"dump":"+---------------------------------------------+\n| REQUEST |\n+---------------------------------------------+\nPOST /GDB HTTP/1.1\r\nHost: 192.168.88.229:1799\r\nUser-Agent: GoFrameHTTPClient v1.16.6\r\nContent-Length: 1296\r\nContent-Type: application/json\r\nAccept-Encoding: gzip\r\n\r\n\n\n\n","error":{"Op":"Post","URL":"http://xxx","Err":{}},"status":"----push error-----"} 但如果单独拿出来请求是可以的,全部都正常返回
func (a *bankInsideApi) TestCurl(r *ghttp.Request) { g.Dump("--000---") content := g.Client().ContentJson().PostContent("http://xxx", g.Map{}) g.Dump("--111--", content) cOntent= g.Client().ContentJson().PostContent("http://xxx", g.Map{ "name": "xxx", "list": g.Array{ g.Map{ "name": "test", "remark": "xxx", "status": "", }, }, }) g.Dump("--22222--", content) } 最近迁移了服务器,go 版本由 1.16 升级到 1.19 ,但这应该不是版本问题吧
求大佬指教
1 lhbc 2023 年 4 月 23 日 via Android 是我水平太差了吗? 我看不懂问什么 |
2 kestrelBright OP @lhbc curl 请求没有返回 |