Skip to content

Commit d539427

Browse files
committed
* lib/net/http, lib/net/https: move content from net/https to
net/http. [ruby-dev:39986] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 190e84b commit d539427

File tree

3 files changed

+34
-46
lines changed

3 files changed

+34
-46
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Fri Jan 8 21:15:21 2010 NARUSE, Yui <[email protected]>
2+
3+
* lib/net/http, lib/net/https: move content from net/https to
4+
net/http. [ruby-dev:39986]
5+
16
Fri Jan 8 14:06:01 2010 NAKAMURA Usaku <[email protected]>
27

38
* io.c (rb_io_s_read): close the IO if an exception is raised on

lib/net/http.rb

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#++
2727

2828
require 'net/protocol'
29+
autoload :OpenSSL, 'openssl'
2930
require 'uri'
3031

3132
module Net #:nodoc:
@@ -544,7 +545,33 @@ def started?
544545

545546
# returns true if use SSL/TLS with HTTP.
546547
def use_ssl?
547-
false # redefined in net/https
548+
@use_ssl
549+
end
550+
551+
# Turn on/off SSL.
552+
# This flag must be set before starting session.
553+
# If you change use_ssl value after session started,
554+
# a Net::HTTP object raises IOError.
555+
def use_ssl=(flag)
556+
flag = (flag ? true : false)
557+
if started? and @use_ssl != flag
558+
raise IOError, "use_ssl value changed, but session already started"
559+
end
560+
@use_ssl = flag
561+
end
562+
563+
SSL_ATTRIBUTES = %w(
564+
ssl_version key cert ca_file ca_path cert_store ciphers
565+
verify_mode verify_callback verify_depth ssl_timeout
566+
)
567+
attr_accessor(*SSL_ATTRIBUTES)
568+
569+
# return the X.509 certificates the server presented.
570+
def peer_cert
571+
if not use_ssl? or not @socket
572+
return nil
573+
end
574+
@socket.io.peer_cert
548575
end
549576

550577
# Opens TCP connection and HTTP session.

lib/net/https.rb

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
=begin
22
3-
= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
3+
= net/https -- SSL/TLS enhancement for Net::HTTP.
44
55
== Info
66
'OpenSSL for Ruby 2' project
@@ -11,16 +11,6 @@
1111
This program is licenced under the same licence as Ruby.
1212
(See the file 'LICENCE'.)
1313
14-
== Requirements
15-
This program requires Net 1.2.0 or higher version.
16-
You can get it from RAA or Ruby's CVS repository.
17-
18-
== Version
19-
$Id$
20-
21-
2001-11-06: Contiributed to Ruby/OpenSSL project.
22-
2004-03-06: Some code is merged in to net/http.
23-
2414
== Example
2515
2616
Here is a simple HTTP client:
@@ -100,37 +90,3 @@
10090

10191
require 'net/http'
10292
require 'openssl'
103-
104-
module Net
105-
class HTTP
106-
remove_method :use_ssl?
107-
def use_ssl?
108-
@use_ssl
109-
end
110-
111-
# Turn on/off SSL.
112-
# This flag must be set before starting session.
113-
# If you change use_ssl value after session started,
114-
# a Net::HTTP object raises IOError.
115-
def use_ssl=(flag)
116-
flag = (flag ? true : false)
117-
if started? and @use_ssl != flag
118-
raise IOError, "use_ssl value changed, but session already started"
119-
end
120-
@use_ssl = flag
121-
end
122-
123-
SSL_ATTRIBUTES = %w(
124-
ssl_version key cert ca_file ca_path cert_store ciphers
125-
verify_mode verify_callback verify_depth ssl_timeout
126-
)
127-
attr_accessor(*SSL_ATTRIBUTES)
128-
129-
def peer_cert
130-
if not use_ssl? or not @socket
131-
return nil
132-
end
133-
@socket.io.peer_cert
134-
end
135-
end
136-
end

0 commit comments

Comments
 (0)