diff --git a/src/mechanize.cr b/src/mechanize.cr index bebf532..7130938 100644 --- a/src/mechanize.cr +++ b/src/mechanize.cr @@ -38,9 +38,9 @@ class Mechanize post_form(uri, form, headers) end + # send POST request from form. def post_form(uri, form, headers) - #cur_page = form.page || current_page || - # Page.new + cur_page = form.page || (current_page unless history.empty?) request_data = form.request_data content_headers = ::HTTP::Headers{ diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index 21a766c..21f235a 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -20,6 +20,7 @@ class MechanizeCr::Form getter enctype : String getter method : String getter name : String + getter page : Page? property action : String def initialize(node : Node | Myhtml::Node, page : Page? = nil) diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index 10dc306..da8a3a4 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -18,7 +18,9 @@ module MechanizeCr @user_agent = "" end - def fetch(uri, method = :get, headers = HTTP::Headers.new, params = Hash(String,String).new) + def fetch(uri, method = :get, headers = HTTP::Headers.new, params = Hash(String,String).new, + )#referer = current_page) + #referer_uri = referer.uri uri = resolve(uri) set_request_headers(uri, headers) set_user_agent