Skip to content

Commit 92b965a

Browse files
committed
In cases where the request that generated this response did not result in an error or exception condition, the attributes and attribute values of the request element must match the key=value pairs of the protocol request;
1 parent ec5483c commit 92b965a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/oai/provider/response.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def required_parameters(*args)
2727
end
2828
def initialize(provider, options = {})
2929
@provider = provider
30+
@request_options = options.dup
3031
@options = internalize(options)
3132
raise OAI::ArgumentException.new unless valid?
3233
end
@@ -35,10 +36,7 @@ def response
3536
@builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
3637
@builder.tag!('OAI-PMH', header) do
3738
@builder.responseDate Time.now.utc.xmlschema
38-
#options parameter has been removed here because with it
39-
#the data won't validate against oai validators. Without, it
40-
#validates.
41-
@builder.request(provider.url) #-- OAI 2.0 Hack - removed request options
39+
@builder.request(provider.url, (@request_options.merge(:verb => verb) unless self.class == Error))
4240
yield @builder
4341
end
4442
end
@@ -113,6 +111,10 @@ def internalize(hash = {})
113111
internal
114112
end
115113

114+
def verb
115+
self.class.to_s.split('::').last
116+
end
117+
116118
end
117119

118120
end

test/provider/tc_provider.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def test_additional_description
1616

1717
def test_list_identifiers_for_correct_xml
1818
doc = REXML::Document.new(@mapped_provider.list_identifiers)
19+
assert_not_nil doc.elements['OAI-PMH/request']
20+
assert_not_nil doc.elements['OAI-PMH/request/@verb']
1921
assert_not_nil doc.elements['OAI-PMH/ListIdentifiers']
2022
assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header']
2123
assert_not_nil doc.elements['OAI-PMH/ListIdentifiers/header/identifier']
@@ -26,6 +28,9 @@ def test_list_identifiers_for_correct_xml
2628
def test_list_records_for_correct_xml
2729
doc = REXML::Document.new(
2830
@mapped_provider.list_records(:metadata_prefix => 'oai_dc'))
31+
assert_not_nil doc.elements['OAI-PMH/request']
32+
assert_not_nil doc.elements['OAI-PMH/request/@verb']
33+
assert_not_nil doc.elements['OAI-PMH/request/@metadata_prefix']
2934
assert_not_nil doc.elements['OAI-PMH/ListRecords/record/header']
3035
assert_not_nil doc.elements['OAI-PMH/ListRecords/record/metadata']
3136
end
@@ -85,6 +90,12 @@ def test_from_and_until
8590
:from => Time.parse("November 1 2000"),
8691
:until => Time.parse("November 30 2000"))
8792
)
93+
94+
assert_not_nil doc.elements['OAI-PMH/request']
95+
assert_not_nil doc.elements['OAI-PMH/request/@verb']
96+
assert_not_nil doc.elements['OAI-PMH/request/@from']
97+
assert_not_nil doc.elements['OAI-PMH/request/@until']
98+
8899
assert_equal 100, doc.elements['OAI-PMH/ListRecords'].to_a.size
89100

90101
doc = REXML::Document.new(

0 commit comments

Comments
 (0)