httparty-cookies 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/library/httparty/cookies.rb +45 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d702f85c0f80242e350b36950258fe6dbd79f3d
|
4
|
+
data.tar.gz: 58ee468f9ae76497e9388fd05a4ef22ddfcec95b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd676da6cc0dde07d0683fda2de8cfb36b3ada03afc1b4a2c60adb477d552f747b5ea81ba906f06b2d817fed6839f3e896eff5961dbffb5002195be7f545de91
|
7
|
+
data.tar.gz: 42e40e2ab26f7faa1feb65b2f8ab340c68f6e573153e8d1d2d18afa7b3b6ae85f79dfbbfe78e390ce337f34476a89dd6d1519c833edec7955c58038e8e55690c
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'httparty'
|
4
|
+
require 'cookiejar'
|
5
|
+
|
6
|
+
module HTTParty
|
7
|
+
module Cookies
|
8
|
+
def self.included base
|
9
|
+
base.send :include, HTTParty
|
10
|
+
base.extend ClassMethods
|
11
|
+
base.send :mattr_inheritable, :cookie_jar
|
12
|
+
base.instance_variable_set :@cookie_jar, CookieJar::Jar.new
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
private
|
17
|
+
def perform_request http_method, path, options, &block
|
18
|
+
options = default_options.dup.merge options
|
19
|
+
|
20
|
+
request = Request.new http_method, path, options
|
21
|
+
process_cookies request
|
22
|
+
response = request.perform(&block)
|
23
|
+
|
24
|
+
# Read cookies from the headers.
|
25
|
+
response.headers.get_fields('Set-Cookie').each do |cookie|
|
26
|
+
uri = response.uri || response.request.uri
|
27
|
+
|
28
|
+
@cookie_jar.set_cookie uri, cookie
|
29
|
+
end
|
30
|
+
|
31
|
+
response
|
32
|
+
end
|
33
|
+
|
34
|
+
# Add cookies from the cookie jar.
|
35
|
+
def process_cookies request
|
36
|
+
cookie_header = @cookie_jar.get_cookie_header request.uri
|
37
|
+
|
38
|
+
unless cookie_header.empty?
|
39
|
+
request.options[:headers] ||= {}
|
40
|
+
request.options[:headers]["cookies"] = cookie_header
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: httparty-cookies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mikkel Kroman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cookiejar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email: mk@uplink.io
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- library/httparty/cookies.rb
|
76
|
+
homepage: https://github.com/mkroman/httparty-cookies
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- library
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.9.1
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.1.3
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: What does every party need? Cookies!
|
100
|
+
test_files: []
|