tionsin
V2EX  ›  Java

Java 中 httpclient 的 cookie 格式化问题

  •  
  •   tionsin · Dec 17, 2019 · 3367 views
    This topic created in 2361 days ago, the information mentioned may be changed or developed.

    背景:

    • 需要用 A 网站 API 登录接口。
    • 使用 java httpclient4.5.6 模拟登录。
    • CookieStore 管理登录态
    • 模拟操作 API

    问题:由于 A 网站 response header 中的 set header 过期时间格式乱码,导致无法正常设置返回的 cookie

    报错: Invalid 'expires' attribute: ��, 20-12��-19 11:26:03 GMT


    现在的情况是,使用默认的 CookieSpecs.STANDARD 解析 cookie,无法成功解析。导致无法进行后续操作。 但是使用自己写的 CookieSpec 解析 cookie 可以成功解析。但是无法登录了。有没有大佬碰到过这类问题。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4657 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 09:54 · PVG 17:54 · LAX 02:54 · JFK 05:54
    ♥ Do have faith in what you're doing.