aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/net/http.rb7
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 32fd37a32c..38adda054a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Sep 14 08:33:11 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
+
+ * lib/net/http.rb (each_*): return enumerator if no block present.
+ Patch by Arthur Schreiber [ruby-core:18310]
+
Mon Sep 14 06:42:21 2009 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/cgi/cookie.rb (value): Keep CGI::Cookie#value in sync with the
diff --git a/lib/net/http.rb b/lib/net/http.rb
index dff0d238dd..512391b19f 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1302,6 +1302,7 @@ module Net #:nodoc:
# Iterates for each header names and values.
def each_header #:yield: +key+, +value+
+ block_given? or return enum_for(__method__)
@header.each do |k,va|
yield k, va.join(', ')
end
@@ -1311,13 +1312,15 @@ module Net #:nodoc:
# Iterates for each header names.
def each_name(&block) #:yield: +key+
+ block_given? or return enum_for(__method__)
@header.each_key(&block)
end
alias each_key each_name
# Iterates for each capitalized header names.
- def each_capitalized_name(&block) #:yield: +key+
+ def each_capitalized_name #:yield: +key+
+ block_given? or return enum_for(__method__)
@header.each_key do |k|
yield capitalize(k)
end
@@ -1325,6 +1328,7 @@ module Net #:nodoc:
# Iterates for each header values.
def each_value #:yield: +value+
+ block_given? or return enum_for(__method__)
@header.each_value do |va|
yield va.join(', ')
end
@@ -1347,6 +1351,7 @@ module Net #:nodoc:
# As for #each_header, except the keys are provided in capitalized form.
def each_capitalized
+ block_given? or return enum_for(__method__)
@header.each do |k,v|
yield capitalize(k), v.join(', ')
end