httsoiree 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/Gemfile +14 -0
- data/Guardfile +16 -0
- data/History +303 -0
- data/MIT-LICENSE +20 -0
- data/README.md +77 -0
- data/Rakefile +12 -0
- data/bin/httparty +117 -0
- data/cucumber.yml +1 -0
- data/examples/aaws.rb +32 -0
- data/examples/basic.rb +28 -0
- data/examples/crack.rb +19 -0
- data/examples/custom_parsers.rb +67 -0
- data/examples/delicious.rb +37 -0
- data/examples/google.rb +16 -0
- data/examples/headers_and_user_agents.rb +6 -0
- data/examples/logging.rb +38 -0
- data/examples/nokogiri_html_parser.rb +22 -0
- data/examples/rubyurl.rb +14 -0
- data/examples/stackexchange.rb +24 -0
- data/examples/tripit_sign_in.rb +33 -0
- data/examples/twitter.rb +31 -0
- data/examples/whoismyrep.rb +10 -0
- data/features/basic_authentication.feature +20 -0
- data/features/command_line.feature +7 -0
- data/features/deals_with_http_error_codes.feature +26 -0
- data/features/digest_authentication.feature +20 -0
- data/features/handles_compressed_responses.feature +27 -0
- data/features/handles_multiple_formats.feature +57 -0
- data/features/steps/env.rb +22 -0
- data/features/steps/httparty_response_steps.rb +52 -0
- data/features/steps/httparty_steps.rb +43 -0
- data/features/steps/mongrel_helper.rb +94 -0
- data/features/steps/remote_service_steps.rb +74 -0
- data/features/supports_read_timeout_option.feature +13 -0
- data/features/supports_redirection.feature +22 -0
- data/features/supports_timeout_option.feature +13 -0
- data/httparty.gemspec +25 -0
- data/lib/httparty/connection_adapter.rb +188 -0
- data/lib/httparty/cookie_hash.rb +22 -0
- data/lib/httparty/core_extensions.rb +32 -0
- data/lib/httparty/exceptions.rb +29 -0
- data/lib/httparty/hash_conversions.rb +51 -0
- data/lib/httparty/logger/apache_logger.rb +22 -0
- data/lib/httparty/logger/curl_logger.rb +48 -0
- data/lib/httparty/logger/logger.rb +18 -0
- data/lib/httparty/module_inheritable_attributes.rb +56 -0
- data/lib/httparty/net_digest_auth.rb +84 -0
- data/lib/httparty/parser.rb +141 -0
- data/lib/httparty/request.rb +339 -0
- data/lib/httparty/response/headers.rb +31 -0
- data/lib/httparty/response.rb +72 -0
- data/lib/httparty/version.rb +3 -0
- data/lib/httparty.rb +618 -0
- data/lib/httsoiree.rb +3 -0
- data/script/release +42 -0
- data/spec/fixtures/delicious.xml +23 -0
- data/spec/fixtures/empty.xml +0 -0
- data/spec/fixtures/google.html +3 -0
- data/spec/fixtures/ssl/generate.sh +29 -0
- data/spec/fixtures/ssl/generated/1fe462c2.0 +16 -0
- data/spec/fixtures/ssl/generated/bogushost.crt +13 -0
- data/spec/fixtures/ssl/generated/ca.crt +16 -0
- data/spec/fixtures/ssl/generated/ca.key +15 -0
- data/spec/fixtures/ssl/generated/selfsigned.crt +14 -0
- data/spec/fixtures/ssl/generated/server.crt +13 -0
- data/spec/fixtures/ssl/generated/server.key +15 -0
- data/spec/fixtures/ssl/openssl-exts.cnf +9 -0
- data/spec/fixtures/twitter.csv +2 -0
- data/spec/fixtures/twitter.json +1 -0
- data/spec/fixtures/twitter.xml +403 -0
- data/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
- data/spec/httparty/connection_adapter_spec.rb +370 -0
- data/spec/httparty/cookie_hash_spec.rb +83 -0
- data/spec/httparty/exception_spec.rb +23 -0
- data/spec/httparty/logger/apache_logger_spec.rb +41 -0
- data/spec/httparty/logger/curl_logger_spec.rb +18 -0
- data/spec/httparty/logger/logger_spec.rb +22 -0
- data/spec/httparty/net_digest_auth_spec.rb +152 -0
- data/spec/httparty/parser_spec.rb +165 -0
- data/spec/httparty/request_spec.rb +774 -0
- data/spec/httparty/response_spec.rb +221 -0
- data/spec/httparty/ssl_spec.rb +74 -0
- data/spec/httparty_spec.rb +783 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/ssl_test_helper.rb +47 -0
- data/spec/support/ssl_test_server.rb +80 -0
- data/spec/support/stub_response.rb +43 -0
- data/website/css/common.css +47 -0
- data/website/index.html +73 -0
- metadata +215 -0
    
        data/spec/spec.opts
    ADDED
    
    
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "httparty"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'spec/autorun'
         | 
| 6 | 
            +
            require 'fakeweb'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            def file_fixture(filename)
         | 
| 9 | 
            +
              open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
         | 
| 10 | 
            +
            end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Spec::Runner.configure do |config|
         | 
| 15 | 
            +
              config.include HTTParty::StubResponse
         | 
| 16 | 
            +
              config.include HTTParty::SSLTestHelper
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              config.before(:suite) do
         | 
| 19 | 
            +
                FakeWeb.allow_net_connect = false
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              config.after(:suite) do
         | 
| 23 | 
            +
                FakeWeb.allow_net_connect = true
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Spec::Matchers.define :use_ssl do
         | 
| 28 | 
            +
              match do |connection|
         | 
| 29 | 
            +
                connection.use_ssl?
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Spec::Matchers.define :use_cert_store do |cert_store|
         | 
| 34 | 
            +
              match do |connection|
         | 
| 35 | 
            +
                connection.cert_store == cert_store
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            require 'pathname'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module HTTParty
         | 
| 4 | 
            +
              module SSLTestHelper
         | 
| 5 | 
            +
                def ssl_verify_test(mode, ca_basename, server_cert_filename, options = {})
         | 
| 6 | 
            +
                  options = {
         | 
| 7 | 
            +
                    format:  :json,
         | 
| 8 | 
            +
                    timeout: 30,
         | 
| 9 | 
            +
                  }.merge(options)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  if mode
         | 
| 12 | 
            +
                    ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__)
         | 
| 13 | 
            +
                    raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path)
         | 
| 14 | 
            +
                    options[mode] = ca_path
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  begin
         | 
| 18 | 
            +
                    test_server = SSLTestServer.new(
         | 
| 19 | 
            +
                        rsa_key: File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)),
         | 
| 20 | 
            +
                        cert:    File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__)))
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    test_server.start
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    if mode
         | 
| 25 | 
            +
                      ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__)
         | 
| 26 | 
            +
                      raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path)
         | 
| 27 | 
            +
                      return HTTParty.get("https://localhost:#{test_server.port}/", options)
         | 
| 28 | 
            +
                    else
         | 
| 29 | 
            +
                      return HTTParty.get("https://localhost:#{test_server.port}/", options)
         | 
| 30 | 
            +
                    end
         | 
| 31 | 
            +
                  ensure
         | 
| 32 | 
            +
                    test_server.stop if test_server
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  test_server = SSLTestServer.new({
         | 
| 36 | 
            +
                    rsa_key: path.join('server.key').read,
         | 
| 37 | 
            +
                    cert:    path.join(server_cert_filename).read,
         | 
| 38 | 
            +
                  })
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  test_server.start
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                  HTTParty.get("https://localhost:#{test_server.port}/", options)
         | 
| 43 | 
            +
                ensure
         | 
| 44 | 
            +
                  test_server.stop if test_server
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
| @@ -0,0 +1,80 @@ | |
| 1 | 
            +
            require 'openssl'
         | 
| 2 | 
            +
            require 'socket'
         | 
| 3 | 
            +
            require 'thread'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # NOTE: This code is garbage.  It probably has deadlocks, it might leak
         | 
| 6 | 
            +
            # threads, and otherwise cause problems in a real system.  It's really only
         | 
| 7 | 
            +
            # intended for testing HTTParty.
         | 
| 8 | 
            +
            class SSLTestServer
         | 
| 9 | 
            +
              attr_accessor :ctx    # SSLContext object
         | 
| 10 | 
            +
              attr_reader :port
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def initialize(options={})
         | 
| 13 | 
            +
                @ctx             = OpenSSL::SSL::SSLContext.new
         | 
| 14 | 
            +
                @ctx.cert        = OpenSSL::X509::Certificate.new(options[:cert])
         | 
| 15 | 
            +
                @ctx.key         = OpenSSL::PKey::RSA.new(options[:rsa_key])
         | 
| 16 | 
            +
                @ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE   # Don't verify client certificate
         | 
| 17 | 
            +
                @port            = options[:port] || 0
         | 
| 18 | 
            +
                @thread          = nil
         | 
| 19 | 
            +
                @stopping_mutex  = Mutex.new
         | 
| 20 | 
            +
                @stopping        = false
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def start
         | 
| 24 | 
            +
                @raw_server = TCPServer.new(@port)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                if @port == 0
         | 
| 27 | 
            +
                  @port = Socket::getnameinfo(@raw_server.getsockname, Socket::NI_NUMERICHOST|Socket::NI_NUMERICSERV)[1].to_i
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                @ssl_server = OpenSSL::SSL::SSLServer.new(@raw_server, @ctx)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                @stopping_mutex.synchronize{
         | 
| 33 | 
            +
                  return if @stopping
         | 
| 34 | 
            +
                  @thread = Thread.new{ thread_main }
         | 
| 35 | 
            +
                }
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                nil
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              def stop
         | 
| 41 | 
            +
                @stopping_mutex.synchronize{
         | 
| 42 | 
            +
                  return if @stopping
         | 
| 43 | 
            +
                  @stopping = true
         | 
| 44 | 
            +
                }
         | 
| 45 | 
            +
                @thread.join
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              private
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def thread_main
         | 
| 51 | 
            +
                  until @stopping_mutex.synchronize{ @stopping }
         | 
| 52 | 
            +
                    (rr,_,_) = select([@ssl_server.to_io], nil, nil, 0.1)
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    next unless rr && rr.include?(@ssl_server.to_io)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                    socket = @ssl_server.accept
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    Thread.new{
         | 
| 59 | 
            +
                      header = []
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                      until (line = socket.readline).rstrip.empty?
         | 
| 62 | 
            +
                        header << line
         | 
| 63 | 
            +
                      end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                      response =<<EOF
         | 
| 66 | 
            +
            HTTP/1.1 200 OK
         | 
| 67 | 
            +
            Connection: close
         | 
| 68 | 
            +
            Content-Type: application/json; charset=UTF-8
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            {"success":true}
         | 
| 71 | 
            +
            EOF
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                      socket.write(response.gsub(/\r\n/n, "\n").gsub(/\n/n, "\r\n"))
         | 
| 74 | 
            +
                      socket.close
         | 
| 75 | 
            +
                  }
         | 
| 76 | 
            +
                  end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                  @ssl_server.close
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            module HTTParty
         | 
| 2 | 
            +
              module StubResponse
         | 
| 3 | 
            +
                def stub_http_response_with(filename)
         | 
| 4 | 
            +
                  format = filename.split('.').last.intern
         | 
| 5 | 
            +
                  data = file_fixture(filename)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  response = Net::HTTPOK.new("1.1", 200, "Content for you")
         | 
| 8 | 
            +
                  response.stub!(:body).and_return(data)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', format: format)
         | 
| 11 | 
            +
                  http_request.stub_chain(:http, :request).and_return(response)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  HTTParty::Request.should_receive(:new).and_return(http_request)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def stub_chunked_http_response_with(chunks)
         | 
| 17 | 
            +
                  response = Net::HTTPResponse.new("1.1", 200, nil)
         | 
| 18 | 
            +
                  response.stub(:chunked_data).and_return(chunks)
         | 
| 19 | 
            +
                  def response.read_body(&block)
         | 
| 20 | 
            +
                    @body || chunked_data.each(&block)
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', format: "html")
         | 
| 24 | 
            +
                  http_request.stub_chain(:http, :request).and_yield(response).and_return(response)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  HTTParty::Request.should_receive(:new).and_return(http_request)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def stub_response(body, code = 200)
         | 
| 30 | 
            +
                  @request.options[:base_uri] ||= 'http://localhost'
         | 
| 31 | 
            +
                  unless defined?(@http) && @http
         | 
| 32 | 
            +
                    @http = Net::HTTP.new('localhost', 80)
         | 
| 33 | 
            +
                    @request.stub!(:http).and_return(@http)
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  response = Net::HTTPResponse::CODE_TO_OBJ[code.to_s].new("1.1", code, body)
         | 
| 37 | 
            +
                  response.stub!(:body).and_return(body)
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  @http.stub!(:request).and_return(response)
         | 
| 40 | 
            +
                  response
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            @media screen, projection {
         | 
| 2 | 
            +
            	/*
         | 
| 3 | 
            +
            	Copyright (c) 2007, Yahoo! Inc. All rights reserved.
         | 
| 4 | 
            +
            	Code licensed under the BSD License:
         | 
| 5 | 
            +
            	http://developer.yahoo.net/yui/license.txt
         | 
| 6 | 
            +
            	version: 2.2.0
         | 
| 7 | 
            +
            	*/
         | 
| 8 | 
            +
            	body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
         | 
| 9 | 
            +
            	body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
         | 
| 10 | 
            +
            	/* end of yahoo reset and fonts */
         | 
| 11 | 
            +
            	
         | 
| 12 | 
            +
            	body 										{color:#333; background:#4b1a1a; line-height:1.3;}
         | 
| 13 | 
            +
            	p												{margin:0 0 20px;}
         | 
| 14 | 
            +
            	a												{color:#4b1a1a;}
         | 
| 15 | 
            +
            	a:hover									{text-decoration:none;}
         | 
| 16 | 
            +
            	strong									{font-weight:bold;}
         | 
| 17 | 
            +
            	em											{font-style:italics;}
         | 
| 18 | 
            +
            	h1,h2,h3,h4,h5,h6				{font-weight:bold;}
         | 
| 19 | 
            +
            	h1											{font-size:197%; margin:30px 0; color:#4b1a1a;}
         | 
| 20 | 
            +
            	h2											{font-size:174%; margin:20px 0; color:#b8111a;}
         | 
| 21 | 
            +
            	h3											{font-size:152%; margin:10px 0;}
         | 
| 22 | 
            +
            	h4											{font-size:129%; margin:10px 0;}
         | 
| 23 | 
            +
            	pre 										{background:#eee; margin:0 0 20px; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
         | 
| 24 | 
            +
            	code										{font-size:100%; margin:0; padding:0;}
         | 
| 25 | 
            +
            	ul, ol									{margin:10px 0 10px 25px;}
         | 
| 26 | 
            +
            	ol li										{margin:0 0 10px;}
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
            	div#wrapper 							{background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
         | 
| 33 | 
            +
            	div#header								{position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
         | 
| 34 | 
            +
            	div#header p							{margin:0; padding:0;}
         | 
| 35 | 
            +
            	div#header h1							{margin:0; padding:0;}
         | 
| 36 | 
            +
            	ul#nav										{position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
         | 
| 37 | 
            +
            	ul#nav li									{display:inline; padding:0 0 0 5px;}
         | 
| 38 | 
            +
            	ul#nav li a								{}
         | 
| 39 | 
            +
            	div#content								{}
         | 
| 40 | 
            +
            	div#footer								{margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
         | 
| 41 | 
            +
             | 
| 42 | 
            +
             | 
| 43 | 
            +
             | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            }
         | 
    
        data/website/index.html
    ADDED
    
    | @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
         | 
| 2 | 
            +
            <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
         | 
| 3 | 
            +
            <head> 
         | 
| 4 | 
            +
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
         | 
| 5 | 
            +
              <title>HTTParty by John Nunemaker</title> 
         | 
| 6 | 
            +
              <link rel="stylesheet" href="css/common.css" type="text/css" /> 
         | 
| 7 | 
            +
            </head> 
         | 
| 8 | 
            +
            <body> 
         | 
| 9 | 
            +
             
         | 
| 10 | 
            +
            <div id="wrapper"> 
         | 
| 11 | 
            +
              <div id="header"> 
         | 
| 12 | 
            +
                <h1>HTTParty</h1> 
         | 
| 13 | 
            +
                <p>Tonight we're gonna HTTParty like it's 1999!</p> 
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                <ul id="nav">
         | 
| 16 | 
            +
                  <li><a href="rdoc/">Docs</a></li> 
         | 
| 17 | 
            +
                  <li><a href="http://github.com/jnunemaker/httparty">Github</a></li>
         | 
| 18 | 
            +
                  <li><a href="http://rubyforge.org/projects/httparty/">Rubyforge</a></li> 
         | 
| 19 | 
            +
                </ul> 
         | 
| 20 | 
            +
              </div> 
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              <div id="content"> 
         | 
| 23 | 
            +
                <h2>Install</h2> 
         | 
| 24 | 
            +
                <pre><code>$ sudo gem install httparty</code></pre> 
         | 
| 25 | 
            +
                
         | 
| 26 | 
            +
                <h2>Some Quick Examples</h2>
         | 
| 27 | 
            +
                
         | 
| 28 | 
            +
                <p>The following is a simple example of wrapping Twitter's API for posting updates.</p>
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            <pre><code>class Twitter
         | 
| 31 | 
            +
              include HTTParty
         | 
| 32 | 
            +
              base_uri 'twitter.com'
         | 
| 33 | 
            +
              basic_auth 'username', 'password'
         | 
| 34 | 
            +
            end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Twitter.post('/statuses/update.json', query: {status: "It's an HTTParty and everyone is invited!"})</code></pre>
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                <p>That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used because of the .json extension in the path of the request. You can also explicitly set a format (see the examples). </p>
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                <p>That works and all but what if you don't want to embed your username and password in the class? Below is an example to fix that:</p>
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            <pre><code>class Twitter
         | 
| 43 | 
            +
              include HTTParty
         | 
| 44 | 
            +
              base_uri 'twitter.com'
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def initialize(u, p)
         | 
| 47 | 
            +
                @auth = {username: u, password: p}
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              def post(text)
         | 
| 51 | 
            +
                options = { query: {status: text}, basic_auth: @auth }
         | 
| 52 | 
            +
                self.class.post('/statuses/update.json', options)
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
            end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")</code></pre>
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                <p><strong>More Examples:</strong> There are <a href="http://github.com/jnunemaker/httparty/tree/master/examples/">several examples in the gem itself</a>.</p>
         | 
| 59 | 
            +
                
         | 
| 60 | 
            +
                <h2>Support</h2> 
         | 
| 61 | 
            +
                <p>Conversations welcome in the <a href="http://groups.google.com/group/httparty-gem">google group</a> and bugs/features over at <a href="http://github.com/jnunemaker/httparty">Github</a>.</p> 
         | 
| 62 | 
            +
                
         | 
| 63 | 
            +
                
         | 
| 64 | 
            +
              </div> 
         | 
| 65 | 
            +
             
         | 
| 66 | 
            +
              <div id="footer"> 
         | 
| 67 | 
            +
                <p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> | 
         | 
| 68 | 
            +
                  <a href="http://orderedlist.com/">Hire Me at Ordered List</a></p> 
         | 
| 69 | 
            +
              </div> 
         | 
| 70 | 
            +
            </div> 
         | 
| 71 | 
            +
             
         | 
| 72 | 
            +
            </body> 
         | 
| 73 | 
            +
            </html>
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,215 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: httsoiree
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.13.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - John Nunemaker
         | 
| 8 | 
            +
            - Sandro Turriate
         | 
| 9 | 
            +
            - Kristján Pétursson
         | 
| 10 | 
            +
            autorequire: 
         | 
| 11 | 
            +
            bindir: bin
         | 
| 12 | 
            +
            cert_chain: []
         | 
| 13 | 
            +
            date: 2014-08-07 00:00:00.000000000 Z
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            +
              name: json
         | 
| 17 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - "~>"
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '1.8'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                requirements:
         | 
| 26 | 
            +
                - - "~>"
         | 
| 27 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 28 | 
            +
                    version: '1.8'
         | 
| 29 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 30 | 
            +
              name: multi_xml
         | 
| 31 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 32 | 
            +
                requirements:
         | 
| 33 | 
            +
                - - ">="
         | 
| 34 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 35 | 
            +
                    version: 0.5.2
         | 
| 36 | 
            +
              type: :runtime
         | 
| 37 | 
            +
              prerelease: false
         | 
| 38 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 39 | 
            +
                requirements:
         | 
| 40 | 
            +
                - - ">="
         | 
| 41 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            +
                    version: 0.5.2
         | 
| 43 | 
            +
            description: Makes http fun! Also, makes consuming restful web services dead easy.
         | 
| 44 | 
            +
            email:
         | 
| 45 | 
            +
            - nunemaker@gmail.com
         | 
| 46 | 
            +
            executables:
         | 
| 47 | 
            +
            - httparty
         | 
| 48 | 
            +
            extensions: []
         | 
| 49 | 
            +
            extra_rdoc_files: []
         | 
| 50 | 
            +
            files:
         | 
| 51 | 
            +
            - ".gitignore"
         | 
| 52 | 
            +
            - ".travis.yml"
         | 
| 53 | 
            +
            - Gemfile
         | 
| 54 | 
            +
            - Guardfile
         | 
| 55 | 
            +
            - History
         | 
| 56 | 
            +
            - MIT-LICENSE
         | 
| 57 | 
            +
            - README.md
         | 
| 58 | 
            +
            - Rakefile
         | 
| 59 | 
            +
            - bin/httparty
         | 
| 60 | 
            +
            - cucumber.yml
         | 
| 61 | 
            +
            - examples/aaws.rb
         | 
| 62 | 
            +
            - examples/basic.rb
         | 
| 63 | 
            +
            - examples/crack.rb
         | 
| 64 | 
            +
            - examples/custom_parsers.rb
         | 
| 65 | 
            +
            - examples/delicious.rb
         | 
| 66 | 
            +
            - examples/google.rb
         | 
| 67 | 
            +
            - examples/headers_and_user_agents.rb
         | 
| 68 | 
            +
            - examples/logging.rb
         | 
| 69 | 
            +
            - examples/nokogiri_html_parser.rb
         | 
| 70 | 
            +
            - examples/rubyurl.rb
         | 
| 71 | 
            +
            - examples/stackexchange.rb
         | 
| 72 | 
            +
            - examples/tripit_sign_in.rb
         | 
| 73 | 
            +
            - examples/twitter.rb
         | 
| 74 | 
            +
            - examples/whoismyrep.rb
         | 
| 75 | 
            +
            - features/basic_authentication.feature
         | 
| 76 | 
            +
            - features/command_line.feature
         | 
| 77 | 
            +
            - features/deals_with_http_error_codes.feature
         | 
| 78 | 
            +
            - features/digest_authentication.feature
         | 
| 79 | 
            +
            - features/handles_compressed_responses.feature
         | 
| 80 | 
            +
            - features/handles_multiple_formats.feature
         | 
| 81 | 
            +
            - features/steps/env.rb
         | 
| 82 | 
            +
            - features/steps/httparty_response_steps.rb
         | 
| 83 | 
            +
            - features/steps/httparty_steps.rb
         | 
| 84 | 
            +
            - features/steps/mongrel_helper.rb
         | 
| 85 | 
            +
            - features/steps/remote_service_steps.rb
         | 
| 86 | 
            +
            - features/supports_read_timeout_option.feature
         | 
| 87 | 
            +
            - features/supports_redirection.feature
         | 
| 88 | 
            +
            - features/supports_timeout_option.feature
         | 
| 89 | 
            +
            - httparty.gemspec
         | 
| 90 | 
            +
            - lib/httparty.rb
         | 
| 91 | 
            +
            - lib/httparty/connection_adapter.rb
         | 
| 92 | 
            +
            - lib/httparty/cookie_hash.rb
         | 
| 93 | 
            +
            - lib/httparty/core_extensions.rb
         | 
| 94 | 
            +
            - lib/httparty/exceptions.rb
         | 
| 95 | 
            +
            - lib/httparty/hash_conversions.rb
         | 
| 96 | 
            +
            - lib/httparty/logger/apache_logger.rb
         | 
| 97 | 
            +
            - lib/httparty/logger/curl_logger.rb
         | 
| 98 | 
            +
            - lib/httparty/logger/logger.rb
         | 
| 99 | 
            +
            - lib/httparty/module_inheritable_attributes.rb
         | 
| 100 | 
            +
            - lib/httparty/net_digest_auth.rb
         | 
| 101 | 
            +
            - lib/httparty/parser.rb
         | 
| 102 | 
            +
            - lib/httparty/request.rb
         | 
| 103 | 
            +
            - lib/httparty/response.rb
         | 
| 104 | 
            +
            - lib/httparty/response/headers.rb
         | 
| 105 | 
            +
            - lib/httparty/version.rb
         | 
| 106 | 
            +
            - lib/httsoiree.rb
         | 
| 107 | 
            +
            - script/release
         | 
| 108 | 
            +
            - spec/fixtures/delicious.xml
         | 
| 109 | 
            +
            - spec/fixtures/empty.xml
         | 
| 110 | 
            +
            - spec/fixtures/google.html
         | 
| 111 | 
            +
            - spec/fixtures/ssl/generate.sh
         | 
| 112 | 
            +
            - spec/fixtures/ssl/generated/1fe462c2.0
         | 
| 113 | 
            +
            - spec/fixtures/ssl/generated/bogushost.crt
         | 
| 114 | 
            +
            - spec/fixtures/ssl/generated/ca.crt
         | 
| 115 | 
            +
            - spec/fixtures/ssl/generated/ca.key
         | 
| 116 | 
            +
            - spec/fixtures/ssl/generated/selfsigned.crt
         | 
| 117 | 
            +
            - spec/fixtures/ssl/generated/server.crt
         | 
| 118 | 
            +
            - spec/fixtures/ssl/generated/server.key
         | 
| 119 | 
            +
            - spec/fixtures/ssl/openssl-exts.cnf
         | 
| 120 | 
            +
            - spec/fixtures/twitter.csv
         | 
| 121 | 
            +
            - spec/fixtures/twitter.json
         | 
| 122 | 
            +
            - spec/fixtures/twitter.xml
         | 
| 123 | 
            +
            - spec/fixtures/undefined_method_add_node_for_nil.xml
         | 
| 124 | 
            +
            - spec/httparty/connection_adapter_spec.rb
         | 
| 125 | 
            +
            - spec/httparty/cookie_hash_spec.rb
         | 
| 126 | 
            +
            - spec/httparty/exception_spec.rb
         | 
| 127 | 
            +
            - spec/httparty/logger/apache_logger_spec.rb
         | 
| 128 | 
            +
            - spec/httparty/logger/curl_logger_spec.rb
         | 
| 129 | 
            +
            - spec/httparty/logger/logger_spec.rb
         | 
| 130 | 
            +
            - spec/httparty/net_digest_auth_spec.rb
         | 
| 131 | 
            +
            - spec/httparty/parser_spec.rb
         | 
| 132 | 
            +
            - spec/httparty/request_spec.rb
         | 
| 133 | 
            +
            - spec/httparty/response_spec.rb
         | 
| 134 | 
            +
            - spec/httparty/ssl_spec.rb
         | 
| 135 | 
            +
            - spec/httparty_spec.rb
         | 
| 136 | 
            +
            - spec/spec.opts
         | 
| 137 | 
            +
            - spec/spec_helper.rb
         | 
| 138 | 
            +
            - spec/support/ssl_test_helper.rb
         | 
| 139 | 
            +
            - spec/support/ssl_test_server.rb
         | 
| 140 | 
            +
            - spec/support/stub_response.rb
         | 
| 141 | 
            +
            - website/css/common.css
         | 
| 142 | 
            +
            - website/index.html
         | 
| 143 | 
            +
            homepage: http://jnunemaker.github.com/httparty
         | 
| 144 | 
            +
            licenses:
         | 
| 145 | 
            +
            - MIT
         | 
| 146 | 
            +
            metadata: {}
         | 
| 147 | 
            +
            post_install_message: 
         | 
| 148 | 
            +
            rdoc_options: []
         | 
| 149 | 
            +
            require_paths:
         | 
| 150 | 
            +
            - lib
         | 
| 151 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 152 | 
            +
              requirements:
         | 
| 153 | 
            +
              - - ">="
         | 
| 154 | 
            +
                - !ruby/object:Gem::Version
         | 
| 155 | 
            +
                  version: 1.9.3
         | 
| 156 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 157 | 
            +
              requirements:
         | 
| 158 | 
            +
              - - ">="
         | 
| 159 | 
            +
                - !ruby/object:Gem::Version
         | 
| 160 | 
            +
                  version: '0'
         | 
| 161 | 
            +
            requirements: []
         | 
| 162 | 
            +
            rubyforge_project: 
         | 
| 163 | 
            +
            rubygems_version: 2.2.2
         | 
| 164 | 
            +
            signing_key: 
         | 
| 165 | 
            +
            specification_version: 4
         | 
| 166 | 
            +
            summary: Makes http fun! Also, makes consuming restful web services dead easy.
         | 
| 167 | 
            +
            test_files:
         | 
| 168 | 
            +
            - features/basic_authentication.feature
         | 
| 169 | 
            +
            - features/command_line.feature
         | 
| 170 | 
            +
            - features/deals_with_http_error_codes.feature
         | 
| 171 | 
            +
            - features/digest_authentication.feature
         | 
| 172 | 
            +
            - features/handles_compressed_responses.feature
         | 
| 173 | 
            +
            - features/handles_multiple_formats.feature
         | 
| 174 | 
            +
            - features/steps/env.rb
         | 
| 175 | 
            +
            - features/steps/httparty_response_steps.rb
         | 
| 176 | 
            +
            - features/steps/httparty_steps.rb
         | 
| 177 | 
            +
            - features/steps/mongrel_helper.rb
         | 
| 178 | 
            +
            - features/steps/remote_service_steps.rb
         | 
| 179 | 
            +
            - features/supports_read_timeout_option.feature
         | 
| 180 | 
            +
            - features/supports_redirection.feature
         | 
| 181 | 
            +
            - features/supports_timeout_option.feature
         | 
| 182 | 
            +
            - spec/fixtures/delicious.xml
         | 
| 183 | 
            +
            - spec/fixtures/empty.xml
         | 
| 184 | 
            +
            - spec/fixtures/google.html
         | 
| 185 | 
            +
            - spec/fixtures/ssl/generate.sh
         | 
| 186 | 
            +
            - spec/fixtures/ssl/generated/1fe462c2.0
         | 
| 187 | 
            +
            - spec/fixtures/ssl/generated/bogushost.crt
         | 
| 188 | 
            +
            - spec/fixtures/ssl/generated/ca.crt
         | 
| 189 | 
            +
            - spec/fixtures/ssl/generated/ca.key
         | 
| 190 | 
            +
            - spec/fixtures/ssl/generated/selfsigned.crt
         | 
| 191 | 
            +
            - spec/fixtures/ssl/generated/server.crt
         | 
| 192 | 
            +
            - spec/fixtures/ssl/generated/server.key
         | 
| 193 | 
            +
            - spec/fixtures/ssl/openssl-exts.cnf
         | 
| 194 | 
            +
            - spec/fixtures/twitter.csv
         | 
| 195 | 
            +
            - spec/fixtures/twitter.json
         | 
| 196 | 
            +
            - spec/fixtures/twitter.xml
         | 
| 197 | 
            +
            - spec/fixtures/undefined_method_add_node_for_nil.xml
         | 
| 198 | 
            +
            - spec/httparty/connection_adapter_spec.rb
         | 
| 199 | 
            +
            - spec/httparty/cookie_hash_spec.rb
         | 
| 200 | 
            +
            - spec/httparty/exception_spec.rb
         | 
| 201 | 
            +
            - spec/httparty/logger/apache_logger_spec.rb
         | 
| 202 | 
            +
            - spec/httparty/logger/curl_logger_spec.rb
         | 
| 203 | 
            +
            - spec/httparty/logger/logger_spec.rb
         | 
| 204 | 
            +
            - spec/httparty/net_digest_auth_spec.rb
         | 
| 205 | 
            +
            - spec/httparty/parser_spec.rb
         | 
| 206 | 
            +
            - spec/httparty/request_spec.rb
         | 
| 207 | 
            +
            - spec/httparty/response_spec.rb
         | 
| 208 | 
            +
            - spec/httparty/ssl_spec.rb
         | 
| 209 | 
            +
            - spec/httparty_spec.rb
         | 
| 210 | 
            +
            - spec/spec.opts
         | 
| 211 | 
            +
            - spec/spec_helper.rb
         | 
| 212 | 
            +
            - spec/support/ssl_test_helper.rb
         | 
| 213 | 
            +
            - spec/support/ssl_test_server.rb
         | 
| 214 | 
            +
            - spec/support/stub_response.rb
         | 
| 215 | 
            +
            has_rdoc: 
         |