glebtv-httpclient 3.0.0
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/README.rdoc +108 -0
- data/bin/httpclient +65 -0
- data/lib/glebtv-httpclient.rb +1 -0
- data/lib/hexdump.rb +50 -0
- data/lib/http-access2/cookie.rb +1 -0
- data/lib/http-access2/http.rb +1 -0
- data/lib/http-access2.rb +55 -0
- data/lib/httpclient/auth.rb +899 -0
- data/lib/httpclient/cacert.p7s +1912 -0
- data/lib/httpclient/connection.rb +88 -0
- data/lib/httpclient/cookie.rb +438 -0
- data/lib/httpclient/http.rb +1050 -0
- data/lib/httpclient/include_client.rb +83 -0
- data/lib/httpclient/session.rb +1031 -0
- data/lib/httpclient/ssl_config.rb +403 -0
- data/lib/httpclient/timeout.rb +140 -0
- data/lib/httpclient/util.rb +186 -0
- data/lib/httpclient/version.rb +3 -0
- data/lib/httpclient.rb +1157 -0
- data/lib/oauthclient.rb +110 -0
- data/sample/async.rb +8 -0
- data/sample/auth.rb +11 -0
- data/sample/cookie.rb +18 -0
- data/sample/dav.rb +103 -0
- data/sample/howto.rb +49 -0
- data/sample/oauth_buzz.rb +57 -0
- data/sample/oauth_friendfeed.rb +59 -0
- data/sample/oauth_twitter.rb +61 -0
- data/sample/ssl/0cert.pem +22 -0
- data/sample/ssl/0key.pem +30 -0
- data/sample/ssl/1000cert.pem +19 -0
- data/sample/ssl/1000key.pem +18 -0
- data/sample/ssl/htdocs/index.html +10 -0
- data/sample/ssl/ssl_client.rb +22 -0
- data/sample/ssl/webrick_httpsd.rb +29 -0
- data/sample/stream.rb +21 -0
- data/sample/thread.rb +27 -0
- data/sample/wcat.rb +21 -0
- data/test/ca-chain.cert +44 -0
- data/test/ca.cert +23 -0
- data/test/client.cert +19 -0
- data/test/client.key +15 -0
- data/test/helper.rb +129 -0
- data/test/htdigest +1 -0
- data/test/htpasswd +2 -0
- data/test/runner.rb +2 -0
- data/test/server.cert +19 -0
- data/test/server.key +15 -0
- data/test/sslsvr.rb +65 -0
- data/test/subca.cert +21 -0
- data/test/test_auth.rb +321 -0
- data/test/test_cookie.rb +412 -0
- data/test/test_hexdump.rb +14 -0
- data/test/test_http-access2.rb +507 -0
- data/test/test_httpclient.rb +1801 -0
- data/test/test_include_client.rb +52 -0
- data/test/test_ssl.rb +235 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9b33e3d213df1ab2e7b7f7f45a41b25d628efc3
|
4
|
+
data.tar.gz: 4a4b694449ca0f15f398007c6a9256a04e74a565
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 45da6038263683200cd2d08a1f2d1f55f3d92e3142152bf0aedee4a63aafa8ea269313812ec3ae400f5415108d264fe95fbb314a14382bf5b88dce6fc591490c
|
7
|
+
data.tar.gz: a1c0f261ecf19047bae79fe2c51062164542388eb6cc301f35758e2ae37eaaae514da421569c38c12769e802bea2a9c536ad7537c07c544f2245638de66515dc
|
data/README.rdoc
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
httpclient - HTTP accessing library.
|
2
|
+
Copyright (C) 2000-2012 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
|
3
|
+
|
4
|
+
'httpclient' gives something like the functionality of libwww-perl (LWP) in
|
5
|
+
Ruby. 'httpclient' formerly known as 'http-access2'.
|
6
|
+
|
7
|
+
See HTTPClient for documentation.
|
8
|
+
|
9
|
+
|
10
|
+
== Features
|
11
|
+
|
12
|
+
* methods like GET/HEAD/POST/* via HTTP/1.1.
|
13
|
+
* HTTPS(SSL), Cookies, proxy, authentication(Digest, NTLM, Basic), etc.
|
14
|
+
* asynchronous HTTP request, streaming HTTP request.
|
15
|
+
* debug mode CLI.
|
16
|
+
|
17
|
+
* by contrast with net/http in standard distribution;
|
18
|
+
* Cookies support
|
19
|
+
* MT-safe
|
20
|
+
* streaming POST (POST with File/IO)
|
21
|
+
* Digest auth
|
22
|
+
* Negotiate/NTLM auth for WWW-Authenticate (requires net/ntlm module; rubyntlm gem)
|
23
|
+
* NTLM auth for Proxy-Authenticate (requires 'win32/sspi' module; rubysspi gem)
|
24
|
+
* extensible with filter interface
|
25
|
+
* you don't have to care HTTP/1.1 persistent connection
|
26
|
+
(httpclient cares instead of you)
|
27
|
+
|
28
|
+
* Not supported now
|
29
|
+
* Cache
|
30
|
+
* Rather advanced HTTP/1.1 usage such as Range, deflate, etc.
|
31
|
+
(of course you can set it in header by yourself)
|
32
|
+
|
33
|
+
== httpclient command
|
34
|
+
|
35
|
+
Usage: 1) % httpclient get https://www.google.co.jp/ q=ruby
|
36
|
+
Usage: 2) % httpclient
|
37
|
+
|
38
|
+
For 1) it issues a GET request to the given URI and shows the wiredump and
|
39
|
+
the parsed result. For 2) it invokes irb shell with the binding that has a
|
40
|
+
HTTPClient as 'self'.
|
41
|
+
|
42
|
+
You can call HTTPClient instance methods like:
|
43
|
+
|
44
|
+
> get "https://www.google.co.jp/", :q => :ruby
|
45
|
+
|
46
|
+
== Author
|
47
|
+
|
48
|
+
Name:: Hiroshi Nakamura
|
49
|
+
E-mail:: nahi@ruby-lang.org
|
50
|
+
Project web site:: http://github.com/nahi/httpclient
|
51
|
+
|
52
|
+
|
53
|
+
== License
|
54
|
+
|
55
|
+
This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
56
|
+
redistribute it and/or modify it under the same terms of Ruby's license;
|
57
|
+
either the dual license version in 2003, or any later version.
|
58
|
+
|
59
|
+
httpclient/session.rb is based on http-access.rb in http-access/0.0.4. Some
|
60
|
+
part of it is copyrighted by Maebashi-san who made and published
|
61
|
+
http-access/0.0.4. http-access/0.0.4 did not include license notice but when
|
62
|
+
I asked Maebashi-san he agreed that I can redistribute it under the same terms
|
63
|
+
of Ruby. Many thanks to Maebashi-san.
|
64
|
+
|
65
|
+
|
66
|
+
== Install
|
67
|
+
|
68
|
+
=== Gem
|
69
|
+
|
70
|
+
You can install httpclient with rubygems.
|
71
|
+
|
72
|
+
% gem install httpclient
|
73
|
+
|
74
|
+
=== Package
|
75
|
+
|
76
|
+
You can install httpclient with the bundled installer script.
|
77
|
+
|
78
|
+
$ ruby install.rb
|
79
|
+
|
80
|
+
It will install lib/* to your site_ruby directory such as
|
81
|
+
/usr/local/lib/ruby/site_ruby/1.8/.
|
82
|
+
|
83
|
+
For uninstall, delete installed files from your site_ruby directory.
|
84
|
+
|
85
|
+
|
86
|
+
== Usage
|
87
|
+
|
88
|
+
See HTTPClient for documentation.
|
89
|
+
You can also check sample/howto.rb how to use APIs.
|
90
|
+
|
91
|
+
|
92
|
+
== Download
|
93
|
+
|
94
|
+
* Gem repository
|
95
|
+
* https://rubygems.org/gems/httpclient
|
96
|
+
|
97
|
+
* git: git://github.com/nahi/httpclient.git
|
98
|
+
|
99
|
+
== Bug report or Feature request
|
100
|
+
|
101
|
+
Please file a ticket at the project web site.
|
102
|
+
|
103
|
+
1. find a similar ticket from https://github.com/nahi/httpclient/issues
|
104
|
+
2. create a new ticket by clicking 'Create Issue' button.
|
105
|
+
3. you can use github features such as pull-request if you like.
|
106
|
+
|
107
|
+
Thanks in advance.
|
108
|
+
|
data/bin/httpclient
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# httpclient shell command.
|
4
|
+
#
|
5
|
+
# Usage: 1) % httpclient get https://www.google.co.jp/ q=ruby
|
6
|
+
# Usage: 2) % httpclient
|
7
|
+
#
|
8
|
+
# For 1) it issues a GET request to the given URI and shows the wiredump and
|
9
|
+
# the parsed result. For 2) it invokes irb shell with the binding that has a
|
10
|
+
# HTTPClient as 'self'. You can call HTTPClient instance methods like;
|
11
|
+
# > get "https://www.google.co.jp/", :q => :ruby
|
12
|
+
require 'httpclient'
|
13
|
+
|
14
|
+
METHODS = ['head', 'get', 'post', 'put', 'delete', 'options', 'propfind', 'proppatch', 'trace']
|
15
|
+
if ARGV.size >= 2 && METHODS.include?(ARGV[0])
|
16
|
+
client = HTTPClient.new
|
17
|
+
client.debug_dev = STDERR
|
18
|
+
$DEBUG = true
|
19
|
+
require 'pp'
|
20
|
+
pp client.send(*ARGV)
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'irb'
|
25
|
+
require 'irb/completion'
|
26
|
+
|
27
|
+
class Runner
|
28
|
+
def initialize
|
29
|
+
@httpclient = HTTPClient.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(msg, *a, &b)
|
33
|
+
debug, $DEBUG = $DEBUG, true
|
34
|
+
begin
|
35
|
+
@httpclient.send(msg, *a, &b)
|
36
|
+
ensure
|
37
|
+
$DEBUG = debug
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def run
|
42
|
+
IRB.setup(nil)
|
43
|
+
ws = IRB::WorkSpace.new(binding)
|
44
|
+
irb = IRB::Irb.new(ws)
|
45
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
46
|
+
|
47
|
+
trap("SIGINT") do
|
48
|
+
irb.signal_handle
|
49
|
+
end
|
50
|
+
|
51
|
+
begin
|
52
|
+
catch(:IRB_EXIT) do
|
53
|
+
irb.eval_input
|
54
|
+
end
|
55
|
+
ensure
|
56
|
+
IRB.irb_at_exit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_s
|
61
|
+
'HTTPClient'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Runner.new.run
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'httpclient'
|
data/lib/hexdump.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: binary
|
2
|
+
|
3
|
+
# This was written by Arai-san and published at
|
4
|
+
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/31987
|
5
|
+
|
6
|
+
|
7
|
+
module HexDump
|
8
|
+
# str must be in BINARY encoding in 1.9
|
9
|
+
def encode(str)
|
10
|
+
offset = 0
|
11
|
+
result = []
|
12
|
+
while raw = str.slice(offset, 16) and raw.length > 0
|
13
|
+
# data field
|
14
|
+
data = ''
|
15
|
+
for v in raw.unpack('N* a*')
|
16
|
+
if v.kind_of? Integer
|
17
|
+
data << sprintf("%08x ", v)
|
18
|
+
else
|
19
|
+
v.each_byte {|c| data << sprintf("%02x", c) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# text field
|
23
|
+
text = raw.tr("\000-\037\177-\377", ".")
|
24
|
+
result << sprintf("%08x %-36s %s", offset, data, text)
|
25
|
+
offset += 16
|
26
|
+
# omit duplicate line
|
27
|
+
if /^(#{regex_quote_n(raw)})+/n =~ str[offset .. -1]
|
28
|
+
result << sprintf("%08x ...", offset)
|
29
|
+
offset += $&.length
|
30
|
+
# should print at the end
|
31
|
+
if offset == str.length
|
32
|
+
result << sprintf("%08x %-36s %s", offset-16, data, text)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
result
|
37
|
+
end
|
38
|
+
module_function :encode
|
39
|
+
|
40
|
+
if RUBY_VERSION >= "1.9"
|
41
|
+
# raw must be in BINARY encoding in 1.9
|
42
|
+
def self.regex_quote_n(raw)
|
43
|
+
Regexp.quote(raw)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
def self.regex_quote_n(raw)
|
47
|
+
Regexp.quote(raw, 'n')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'httpclient/cookie'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'httpclient/http'
|
data/lib/http-access2.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# HTTPAccess2 - HTTP accessing library.
|
2
|
+
# Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
|
3
|
+
|
4
|
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
5
|
+
# redistribute it and/or modify it under the same terms of Ruby's license;
|
6
|
+
# either the dual license version in 2003, or any later version.
|
7
|
+
|
8
|
+
# http-access2.rb is based on http-access.rb in http-access/0.0.4. Some
|
9
|
+
# part of it is copyrighted by Maebashi-san who made and published
|
10
|
+
# http-access/0.0.4. http-access/0.0.4 did not include license notice but
|
11
|
+
# when I asked Maebashi-san he agreed that I can redistribute it under the
|
12
|
+
# same terms of Ruby. Many thanks to Maebashi-san.
|
13
|
+
|
14
|
+
|
15
|
+
require 'httpclient'
|
16
|
+
|
17
|
+
|
18
|
+
module HTTPAccess2
|
19
|
+
VERSION = ::HTTPClient::VERSION
|
20
|
+
RUBY_VERSION_STRING = ::HTTPClient::RUBY_VERSION_STRING
|
21
|
+
SSLEnabled = ::HTTPClient::SSLEnabled
|
22
|
+
SSPIEnabled = ::HTTPClient::SSPIEnabled
|
23
|
+
DEBUG_SSL = true
|
24
|
+
|
25
|
+
Util = ::HTTPClient::Util
|
26
|
+
|
27
|
+
class Client < ::HTTPClient
|
28
|
+
class RetryableResponse < StandardError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
SSLConfig = ::HTTPClient::SSLConfig
|
33
|
+
BasicAuth = ::HTTPClient::BasicAuth
|
34
|
+
DigestAuth = ::HTTPClient::DigestAuth
|
35
|
+
NegotiateAuth = ::HTTPClient::NegotiateAuth
|
36
|
+
AuthFilterBase = ::HTTPClient::AuthFilterBase
|
37
|
+
WWWAuth = ::HTTPClient::WWWAuth
|
38
|
+
ProxyAuth = ::HTTPClient::ProxyAuth
|
39
|
+
Site = ::HTTPClient::Site
|
40
|
+
Connection = ::HTTPClient::Connection
|
41
|
+
SessionManager = ::HTTPClient::SessionManager
|
42
|
+
SSLSocketWrap = ::HTTPClient::SSLSocketWrap
|
43
|
+
DebugSocket = ::HTTPClient::DebugSocket
|
44
|
+
|
45
|
+
class Session < ::HTTPClient::Session
|
46
|
+
class Error < StandardError
|
47
|
+
end
|
48
|
+
class InvalidState < Error
|
49
|
+
end
|
50
|
+
class BadResponse < Error
|
51
|
+
end
|
52
|
+
class KeepAliveDisconnected < Error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|