<commit_before>excon
=====

Http(s) EXtended CONnections

[![Build Status](https://secure.travis-ci.org/geemus/excon.png)](http://travis-ci.org/geemus/excon)
[![Dependency Status](https://gemnasium.com/geemus/excon.png)](https://gemnasium.com/geemus/excon)
[![Gem Version](https://fury-badge.herokuapp.com/rb/excon.png)](http://badge.fury.io/rb/excon)

Getting Started
---------------

Install the gem.

    $ sudo gem install excon

Require with rubygems.

    require 'rubygems'
    require 'excon'

The simplest way to use excon is with one-off requests:

    response = Excon.get('http://geemus.com')

Supported one-off request methods are #connect, #delete, #get, #head, #options, #post, #put, and #trace.

The returned response object has #body, #headers and #status attributes.

Alternately you can create a connection object which is reusable across multiple requests (more performant!).

    connection = Excon.new('http://geemus.com')
    response_one = connection.get
    response_two = connection.post(:path => '/foo')
    response_three = connection.delete(:path => '/bar')

Sometimes it is more convenient to specify the request type as an argument:

    response_four = connection.request(:method => :get, :path => '/more')

Both one-off and persistent connections support many other options. Here are a few common examples:

    # Custom headers
    Excon.get('http://geemus.com', :headers => {'Authorization' => 'Basic 0123456789ABCDEF'})
    connection.get(:headers => {'Authorization' => 'Basic 0123456789ABCDEF'})

    # Changing query strings
    connection = Excon.new('http://geemus.com/')
    connection.get(:query => {:foo => 'bar'})

    # POST body
    Excon.post('http://geemus.com', :body => 'language=ruby&class=fog')

    # request accepts either symbols or strings
    connection.request(:method => :get)
    connection.request(:method => 'GET')

    # this request can be repeated safely, so retry on errors up to 3 times
    connection.request(:idempotent => true)

    # this request can be repeated safely, retry up to 6 times
    connection.request(:idempotent => true, :retry_limit => 6)

    # opt out of nonblocking operations for performance and/or as a workaround
    connection.request(:nonblock => false)
<commit_msg>Include example using `URI.encode_www_form`<commit_after>excon
=====

Http(s) EXtended CONnections

[![Build Status](https://secure.travis-ci.org/geemus/excon.png)](http://travis-ci.org/geemus/excon)
[![Dependency Status](https://gemnasium.com/geemus/excon.png)](https://gemnasium.com/geemus/excon)
[![Gem Version](https://fury-badge.herokuapp.com/rb/excon.png)](http://badge.fury.io/rb/excon)

Getting Started
---------------

Install the gem.

    $ sudo gem install excon

Require with rubygems.

    require 'rubygems'
    require 'excon'

The simplest way to use excon is with one-off requests:

    response = Excon.get('http://geemus.com')

Supported one-off request methods are #connect, #delete, #get, #head, #options, #post, #put, and #trace.

The returned response object has #body, #headers and #status attributes.

Alternately you can create a connection object which is reusable across multiple requests (more performant!).

    connection = Excon.new('http://geemus.com')
    response_one = connection.get
    response_two = connection.post(:path => '/foo')
    response_three = connection.delete(:path => '/bar')

Sometimes it is more convenient to specify the request type as an argument:

    response_four = connection.request(:method => :get, :path => '/more')

Both one-off and persistent connections support many other options. Here are a few common examples:

    # Custom headers
    Excon.get('http://geemus.com', :headers => {'Authorization' => 'Basic 0123456789ABCDEF'})
    connection.get(:headers => {'Authorization' => 'Basic 0123456789ABCDEF'})

    # Changing query strings
    connection = Excon.new('http://geemus.com/')
    connection.get(:query => {:foo => 'bar'})

    # POST body
    Excon.post('http://geemus.com', :body => 'language=ruby&class=fog')

    # same again, but using URI to build the body of parameters
    Excon.post('http://geemus.com', :body => URI.encode_www_form(:language => 'ruby', :class => 'fog'))

    # request accepts either symbols or strings
    connection.request(:method => :get)
    connection.request(:method => 'GET')

    # this request can be repeated safely, so retry on errors up to 3 times
    connection.request(:idempotent => true)

    # this request can be repeated safely, retry up to 6 times
    connection.request(:idempotent => true, :retry_limit => 6)

    # opt out of nonblocking operations for performance and/or as a workaround
    connection.request(:nonblock => false)

{'fraction_non_alphanumeric': 0.14107180682058887, 'fraction_numerical': 0.00974369836898962, 'mean_word_length': 3.9393305439330546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 40, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4636206', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1404, 'n_words': 416}