HTTPal 25 → 30

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/Rakefile CHANGED
@@ -7,15 +7,15 @@
7
7
  # See COPYING in the httpal root for the full license.
8
8
  #
9
9
  # Subversion info:
10
- # $Id: Rakefile 25 2007-03-17 20:11:44Z bkerley $
10
+ # $Id: Rakefile 29 2007-03-23 15:43:09Z bkerley $
11
11
 
12
12
  require 'rake'
13
13
  require 'rake/testtask'
14
14
  require 'rake/gempackagetask'
15
15
  require 'rubygems'
16
16
 
17
- ID = "$Id: Rakefile 25 2007-03-17 20:11:44Z bkerley $"
18
- GEM_VERSION = ID.split[2]
17
+ ID = "$Id: Rakefile 29 2007-03-23 15:43:09Z bkerley $"
18
+ GEM_VERSION = `svnversion`.split(':')[0].chop
19
19
 
20
20
  #this will probably fail in win32
21
21
  HOMEDIR = ENV['HOME']
@@ -1,15 +1,14 @@
1
1
  #
2
2
  # httpal/lib/httpal.rb
3
3
  #
4
- # Created by Bryce Kerley on 2006-12-31.
5
- # Copyright (c) 2006-2007 Bryce Kerley. All rights reserved.
6
4
  # This software is licensed under the GNU LGPL 2.1 .
7
5
  # See COPYING in the httpal root for the full license.
8
6
  #
9
7
  # Subversion info:
10
- # $Id: httpal.rb 20 2007-02-08 02:13:16Z bkerley $
8
+ # $Id: httpal.rb 27 2007-03-23 15:21:54Z bkerley $
11
9
  $:.unshift File.dirname(__FILE__)
12
10
  require 'net/http'
11
+ require 'net/https'
13
12
  require 'uri'
14
13
 
15
14
  require 'httpal/browser.rb'
@@ -7,7 +7,7 @@
7
7
  # See COPYING in the httpal root for the full license.
8
8
  #
9
9
  # Subversion info:
10
- # $Id: browser.rb 20 2007-02-08 02:13:16Z bkerley $
10
+ # $Id: browser.rb 28 2007-03-23 15:41:07Z bkerley $
11
11
  module HTTPal
12
12
  class Browser
13
13
 
@@ -37,7 +37,7 @@ module HTTPal
37
37
 
38
38
  def parseuri(uri)
39
39
  uri = URI.parse(uri) unless uri.is_a? URI::HTTP
40
- path = uri.path
40
+ path = uri.path.empty? ? '/' : uri.path
41
41
  path << '?' << uri.query if uri.query
42
42
  return [uri, path]
43
43
  end
@@ -46,7 +46,11 @@ module HTTPal
46
46
  req['cookie'] = get_cookies_for_uri(uri)
47
47
  req['referer'] =get_referer
48
48
 
49
- res = Net::HTTP.new(uri.host, uri.port ? uri.port : 80).start {|http| http.request(req)}
49
+ default_port = uri.scheme == "https" ? "443" : "80"
50
+ http = Net::HTTP.new(uri.host, uri.port ? uri.port : default_port)
51
+ http.use_ssl = true if uri.scheme == "https"
52
+
53
+ res = http.start {|http| http.request(req)}
50
54
  set_cookie_for_uri(uri, res['set-cookie'])
51
55
  set_referer(uri)
52
56
 
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # httpal/tests/https_test.rb
3
+ #
4
+ # Created by Bryce Kerley on 2006-12-28.
5
+ # Copyright (c) 2006-2007 Bryce Kerley. All rights reserved.
6
+ # This software is licensed under the GNU LGPL 2.1 .
7
+ # See COPYING in the httpal root for the full license.
8
+ #
9
+ # Subversion info:
10
+ # $Id: https_test.rb 28 2007-03-23 15:41:07Z bkerley $
11
+ require File.join(File.dirname(__FILE__), 'test_helper')
12
+
13
+ class HTTPSTest < Test::Unit::TestCase
14
+
15
+ def test_https
16
+ resp = nil
17
+ HTTPal::Browser.new.use {
18
+ resp = get('https://www.ruby-lang.org/')
19
+ }
20
+ # This test will need to change if this url ever becomes not-301
21
+ assert_equal '301', resp.code
22
+ end
23
+
24
+ def test_https_alternate_port
25
+ resp = nil
26
+ HTTPal::Browser.new.use {
27
+ resp = get('https://test.gnutls.org:5556/')
28
+ }
29
+ assert_equal '200', resp.code
30
+ end
31
+
32
+ end
@@ -7,7 +7,7 @@
7
7
  # See COPYING in the httpal root for the full license.
8
8
  #
9
9
  # Subversion info:
10
- # $Id: original_test.rb 20 2007-02-08 02:13:16Z bkerley $
10
+ # $Id: original_test.rb 28 2007-03-23 15:41:07Z bkerley $
11
11
  require File.join(File.dirname(__FILE__), 'test_helper')
12
12
 
13
13
  class OriginalTest < Test::Unit::TestCase
@@ -48,4 +48,12 @@ class OriginalTest < Test::Unit::TestCase
48
48
  }
49
49
  assert_equal 'you do', resp.body
50
50
  end
51
+
52
+ def test_no_slash
53
+ resp = nil
54
+ HTTPal::Browser.new.use {
55
+ resp = get('http://www.brycekerley.net')
56
+ }
57
+ assert_equal '302', resp.code
58
+ end
51
59
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: HTTPal
5
5
  version: !ruby/object:Gem::Version
6
- version: "25"
7
- date: 2007-03-17 00:00:00 -04:00
6
+ version: "30"
7
+ date: 2007-03-23 00:00:00 -04:00
8
8
  summary: HTTP browser library
9
9
  require_paths:
10
10
  - lib
@@ -55,6 +55,7 @@ files:
55
55
  - lib/httpal.rb
56
56
  - lib/httpal/browser.rb
57
57
  - lib/httpal/cookie.rb
58
+ - tests/https_test.rb
58
59
  - tests/original_test.rb
59
60
  - tests/test_helper.rb
60
61
  - README
metadata.gz.sig CHANGED
Binary file