rogerleite / http_monkey Goto Github PK
View Code? Open in Web Editor NEWA fluent interface to do HTTP calls, free of fat dependencies and at same time, powered by middlewares rack.
License: MIT License
A fluent interface to do HTTP calls, free of fat dependencies and at same time, powered by middlewares rack.
License: MIT License
Support encrypted requests, certificate configuration.
Maintain (and uses) cookies through requests.
Support the ability to do several parallel requests and to gather all the responses in a array.
Something like:
HttpMonkey.configure do
middlewares.use HttpMonkey::Middlewares::RequestFilter do |request|
# HTTPI::Request, you can set proxy, timeouts, authentication etc.
end
end
Support custom HTTP methods such as PURGE, or anything else
Users must have a easy way to use the raw or converted to ruby objects values of the request or response headers specified in the RFC [1, 2].
Only RFC specified headers are accessed by these helpers, extensions should be available only by the Hash.
For complex values, the implementation should do a lazy instantiation of the objects involved.
For value types, check [3, 4]. The lists below shows what value a header will get after converting from raw value. Some of the headers will be improved on later milestones (check "improve later" headers, below):
general-header = Cache-Control ; check [5, 6]
| Connection ; token (1*<any CHAR except CTLs or separators>) > string
| Date ; HTTP-date [7]
| Pragma ; token > string
| Trailer ; #field-name > string
| Transfer-Encoding ; #transfer-coding > string (improve later)
| Upgrade ; token > string
| Via ; 1#( received-protocol received-by [ comment ] ) > string (improve later)
| Warning ; 1#warning-value > Object with code, agent, text, [date]
entity-header = Allow ; #Method > string (normalization to all caps)
| Content-Encoding ; 1#content-coding > string (improve later)
| Content-Language ; 1#language-tag > array of langs
| Content-Length ; Integer
| Content-Location ; ( absoluteURI | relativeURI ) > Object uri
| Content-MD5 ; <base64 of 128 bit MD5 digest as per RFC 1864> > string (maybe provide helper for that)
| Content-Range ; content-range-spec (see Range, below) > string (improve later)
| Content-Type ; media-type [9] > Object mediatype, charset
| Expires ; HTTP-date [7]
| Last-Modified ; HTTP-date [7]
request-header = Accept ; #( media-range [ accept-params ] ) > Object
| Accept-Charset ; 1#( ( charset | "*" )[ ";" "q" "=" qvalue ] ) > Object
| Accept-Encoding ; 1#( codings [ ";" "q" "=" qvalue ] ) > Object
| Accept-Language ; 1#( language-range [ ";" "q" "=" qvalue ] ) > Object
| Authorization ; Object? Gem? Middleware? (improve later) [8]
| Expect ; 1#expectation > string (improve later)
| From ; mailbox > string (maybe improve later)
| Host ; HTTP URL (sect 3.2.2) > Object uri
| If-Match ; entity-tag (sect 3.11) > quoted string (maybe object)
| If-Modified-Since ; HTTP-date [7]
| If-None-Match ; entity-tag (sect 3.11) > quoted string (maybe object)
| If-Range ; HTTP-date [7] | entity-tag
| If-Unmodified-Since ; HTTP-date [7]
| Max-Forwards ; Integer
| Proxy-Authorization ; Object? Gem? Middleware? (improve later) [8]
| Range ; byte-ranges-specifier | ranges-specifier > string (improve later)
| Referer ; absoluteURI | relativeURI > Object URI
| TE ; #( t-codings ) > string (improve later)
| User-Agent ; 1*( product | comment ) > string (improve later [wurfl?])
response-header = Accept-Ranges ; 1#range-unit | "none" > string (maybe improve later)
| Age ; Integer
| ETag ; entity-tag (sect 3.11) > quoted string (maybe object)
| Location ; absoluteURI > object uri
| Proxy-Authenticate ; 1#challenge > string (improve later)
| Retry-After ; HTTP-date | delta-seconds (Integer)
| Server ; 1*( product | comment ) > string (improve later)
| Vary ; "*" | 1#field-name > string (maybe improve later)
| WWW-Authenticate ; 1#challenge > string (improve later)
[1] http://www.w3.org/Protocols/rfc2616/rfc2616.html
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14
[3] http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2
[4] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3
[5] https://github.com/abril/cachebag/blob/master/lib/cachebag/cache_control.rb
[6] https://github.com/abril/cachebag/blob/master/test/cachebag/cache_control_test.rb
[7] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
[8] http://www.ietf.org/rfc/rfc2617.txt
[9] http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
As specified in [1].
Should also support configuration of keep-alive sessions.
[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1
[2] http://en.wikipedia.org/wiki/HTTP_persistent_connection
Follow redirect have to be optional.
I'm planning to implement as middleware, something like this:
HttpMonkey.configure do
middlewares.use HttpMonkey::M::FollowRedirect, :max_tries => 3
end
Use Readme information, organize and publish at gh-pages.
Hi Roger,
First of all, nice work!
Are you willing to implement a feature that "respect" the max-age of the requested file in a way that we can choose where to cache the requested file - like a memcached or something - to intercept the HTTP request before http_monkey does. Would be nice if get started a new thread to discuss about this.
Move all information and leave the necessary.
HTTP clients should be compliant with the nomenclature established by the HTTP RFC [1, 2]. This issue addresses the verification of:
[1] http://www.w3.org/Protocols/rfc2616/rfc2616.html
[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec1.html#sec1.3
Support the ability to do non-blocking requests and handle responses in callbacks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.