From 900d5a419a0164c5f080092ca33320d303a60763 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Mon, 9 Aug 2021 19:11:38 +0900 Subject: [PATCH] make MechanizeCr::History --- src/mechanize/history.cr | 9 +++++++++ src/mechanize/http/agent.cr | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/mechanize/history.cr diff --git a/src/mechanize/history.cr b/src/mechanize/history.cr new file mode 100644 index 0000000..f002b2a --- /dev/null +++ b/src/mechanize/history.cr @@ -0,0 +1,9 @@ +require "./page" + +class MechanizeCr::History < Array(MechanizeCr::Page) + property :max_size + def initialize(max_size = 100) + @max_size = max_size + super + end +end diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index ecc7fe7..ec232a1 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -1,17 +1,18 @@ require "uri" require "http/client" require "../cookie" +require "../history" module MechanizeCr module HTTP class Agent property :request_headers, :context - property history : Array(Page) + property history : MechanizeCr::History property user_agent : String property request_cookies : ::HTTP::Cookies def initialize(@context : Mechanize | Nil = nil) - @history = Array(Page).new + @history = MechanizeCr::History.new @request_headers = ::HTTP::Headers.new @context = context @request_cookies = ::HTTP::Cookies.new