V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ankle306
V2EX  ›  问与答

HttpUrlConnection 和 HttpClient 请求相同,为什么返回值不同?

  •  
  •   ankle306 · 2017-09-28 15:51:05 +08:00 · 1611 次点击
    这是一个创建于 2615 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在做易宝对账的时候,用 HttpUrlConnection 发送 POST 请求,返回 error,用 HttpClient 就正常,所以请教一下大家是什么原因,下面的数据是用 Fiddler 抓的包。 authorize_no 是商户账户,certify_token 是 AES 加密后的数据


    #HttpUrlConnection request

    POST http://o2o.yeepay.com/zgt/auth/AuthDown/downloadOrderDocument HTTP/1.1 User-Agent: Apache-HttpClient/4.5 Accept-Encoding: gzip,deflate Content-Type: application/x-www-formurlencoded Content-Length: 327 Host: o2o.yeepay.com Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2 Connection: keep-alive

    authorize_no=10000447996&certify_token=F1C00E69D568BF1F130BEA29083EB7E6596F19B3243202C175388864AA4C0327E14938D6774B657CC44C5C4EA8377B30B61A5CD2D399FCA087E28D62E86F0D69439A93FA913D39D2C4F5ADCB38B364F91BA9B1EDA114DF5C556A15286D9A68CF326E89117E4420CECC9E62E41B8816B451290A26D573367923E9CB59E6EEA970A27F0F8B953872162D7C594542561ADC

    #response

    HTTP/1.1 200 OK Server: Tengine/2.1.1 Date: Thu, 28 Sep 2017 07:34:33 GMT Content-Length: 34 Connection: keep-alive Set-Cookie: JSESSIONID=52D08DC323ACB46371D0E8E014C1AD07; Path=/zgt/; HttpOnly Set-Cookie: BIGipServerpool_ad_O2O_app_http=2752161984.36895.0000; expires=Thu, 28-. Sep-2017 08:04:33 GMT; path=/

    {"error":"请求参数有误!"}


    #HttpClient request

    POST http://o2o.yeepay.com/zgt/auth/AuthDown/downloadOrderDocument HTTP/1.1 Content-Length: 327 Content-Type: application/x-www-form-urlencoded Host: o2o.yeepay.com Connection: Keep-Alive User-Agent: Apache-HttpClient/4.5 (Java/1.6.0_13) Accept-Encoding: gzip,deflate

    authorize_no=10000447996&certify_token=F1C00E69D568BF1F130BEA29083EB7E6596F19B3243202C175388864AA4C0327E14938D6774B657CC44C5C4EA8377B30B61A5CD2D399FCA087E28D62E86F0D69439A93FA913D39D2C4F5ADCB38B364F91BA9B1EDA114DF5C556A15286D9A68CF326E89117E4420CECC9E62E41B8816B451290A26D573367923E9CB59E6EEA970A27F0F8B953872162D7C594542561ADC

    #response

    HTTP/1.1 200 OK Server: Tengine/2.1.1 Date: Thu, 28 Sep 2017 07:34:49 GMT Content-Length: 93 Connection: keep-alive Set-Cookie: JSESSIONID=DE761135579D1154CC90DCA94A25E6B9; Path=/zgt/; HttpOnly Set-Cookie: BIGipServerpool_ad_O2O_app_http=2802493632.36895.0000; expires=Thu, 28-Sep-2017 08:04:49 GMT; path=/

    {"message":"10000447996 请求的 2017-09-27pay 类型的 txt 文件不存在!","success":false}

    1 条回复    2017-09-28 17:15:36 +08:00
    nazor
        1
    nazor  
       2017-09-28 17:15:36 +08:00
    Accept: text/html, image/gif, image/jpeg, *; q=.2, /; q=.2
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5649 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 08:11 · PVG 16:11 · LAX 00:11 · JFK 03:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.