Method: PostageApp::Request#send
- Defined in:
- lib/postageapp/request.rb
#send(skip_failed_requests_processing = false) ⇒ Object
Skipping resend doesn’t trigger PostageApp::FailedRequest.resend_all it’s needed so the request being resend doesn’t create duplicate queue
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/postageapp/request.rb', line 32 def send(skip_failed_requests_processing = false) http = Net::HTTP::Proxy( PostageApp.configuration.proxy_host, PostageApp.configuration.proxy_port, PostageApp.configuration.proxy_user, PostageApp.configuration.proxy_pass ).new(url.host, url.port) http.read_timeout = PostageApp.configuration.http_read_timeout http.open_timeout = PostageApp.configuration.http_open_timeout http.use_ssl = PostageApp.configuration.secure? PostageApp.logger.info(self) http_response = begin http.post( url.path, self.arguments_to_send.to_json, HEADERS.merge('User-Agent' => "PostageApp-RubyGem #{PostageApp::VERSION} (Ruby #{RUBY_VERSION}, #{PostageApp.configuration.framework})") ) rescue TimeoutError, Errno::ECONNREFUSED nil end response = PostageApp::Response.new(http_response) PostageApp.logger.info(response) unless skip_failed_requests_processing if response.fail? PostageApp::FailedRequest.store(self) elsif response.ok? PostageApp::FailedRequest.resend_all end end response end |