httparty-cookies 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/library/httparty-cookies.rb +1 -0
- data/library/httparty/cookies.rb +8 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8adba4b26445366e76b43092c516a96f223f42d7
|
4
|
+
data.tar.gz: 564ac260d86d2c4d94aafe797b0c50c3d167c8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cd50739f85e35b2b08c485d8504eeffdd94978307b7b5c2da1b0e05ceca6fc126e529317624d2c64b290c3037305e582166e7a70a075ecebfd562715ef6b4c
|
7
|
+
data.tar.gz: 591577c02a0a10fa951533cf48aff81ae3438630bcedd3e7cedd84fc546cf46ac572724af6d53bf6aa75a72c8aec2cb3d8a367d40f2cf3e41ddb2ba55b768bd0
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'httparty/cookies'
|
data/library/httparty/cookies.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'httparty'
|
4
|
-
require '
|
4
|
+
require 'http-cookie'
|
5
5
|
|
6
6
|
module HTTParty
|
7
7
|
module Cookies
|
8
8
|
def self.included base
|
9
|
+
# Include HTTParty first
|
9
10
|
base.send :include, HTTParty
|
10
11
|
base.extend ClassMethods
|
11
12
|
base.send :mattr_inheritable, :cookie_jar
|
12
|
-
|
13
|
+
|
14
|
+
# Create a new cookie jar
|
15
|
+
base.instance_variable_set :@cookie_jar, HTTP::CookieJar.new
|
13
16
|
end
|
14
17
|
|
15
18
|
module ClassMethods
|
16
|
-
private
|
17
19
|
def perform_request http_method, path, options, &block
|
18
20
|
options = default_options.dup.merge options
|
19
21
|
|
@@ -22,10 +24,10 @@ module HTTParty
|
|
22
24
|
response = request.perform(&block)
|
23
25
|
|
24
26
|
# Read cookies from the headers.
|
25
|
-
response.headers.get_fields('
|
27
|
+
response.headers.get_fields('set-cookie').each do |value|
|
26
28
|
uri = response.uri || response.request.uri
|
27
29
|
|
28
|
-
@cookie_jar.
|
30
|
+
@cookie_jar.parse value, uri
|
29
31
|
end
|
30
32
|
|
31
33
|
response
|
@@ -33,7 +35,7 @@ module HTTParty
|
|
33
35
|
|
34
36
|
# Add cookies from the cookie jar.
|
35
37
|
def process_cookies request
|
36
|
-
cookie_header = @cookie_jar.
|
38
|
+
cookie_header = HTTP::Cookie.cookie_value @cookie_jar.cookies request.uri
|
37
39
|
|
38
40
|
unless cookie_header.empty?
|
39
41
|
request.options[:headers] ||= {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httparty-cookies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Kroman
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: http-cookie
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|
@@ -73,6 +73,7 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- library/httparty/cookies.rb
|
76
|
+
- library/httparty-cookies.rb
|
76
77
|
homepage: https://github.com/mkroman/httparty-cookies
|
77
78
|
licenses:
|
78
79
|
- MIT
|