Crystal: HTTP::Client::Response.cookies Invalid Int32 (ArgumentError)

Created on 4 Feb 2020  路  1Comment  路  Source: crystal-lang/crystal

Summary

  • Problems caused by bad cookie parsing implementation.

    • Maybe it should use UInt64 (to_u64)? Or something.

      Sample


require "http"

payload = %(HTTP/1.1 200 OK
Date: Tue, 04 Feb 2020 19:56:19 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Server: openresty
X-Powered-By: HHVM/3.7.3-dev
Vary: Accept-Encoding
Set-Cookie: h5_user_id=H5UserId_1584511; expires=Thu, 11-Jan-2120 19:56:19 GMT; Max-Age=3153600000; path=/; domain=k.e
X-Location: /

)

response = HTTP::Client::Response.from_io IO::Memory.new payload
response.cookies

Verbose

Unhandled exception: Invalid Int32: 3153600000 (ArgumentError)
  from unwind
  from initialize
  from new
  from raise
  from to_i32
  from to_i
  from parse_set_cookie
  from fill_from_headers
  from from_headers
  from cookies
  from __crystal_main
  from main_user_code
  from main
  from main
bug stdlib

Most helpful comment

Parsing Int64 should be sufficient.

>All comments

Parsing Int64 should be sufficient.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArthurZ picture ArthurZ  路  3Comments

cjgajard picture cjgajard  路  3Comments

lgphp picture lgphp  路  3Comments

oprypin picture oprypin  路  3Comments

relonger picture relonger  路  3Comments