Module: Stash::Sword::HeaderUtils
- Included in:
- Client
- Defined in:
- lib/stash/sword/header_utils.rb
Constant Summary collapse
- SIMPLE_ZIP =
'http://purl.org/net/sword/package/SimpleZip'.freeze
- APPLICATION_ZIP =
'application/zip'.freeze
- MULTIPART_RELATED_ATOM_XML =
'multipart/related; type="application/atom+xml"'.freeze
- CONTENT_DISPOSITION =
'attachment'.freeze
Instance Attribute Summary collapse
-
#on_behalf_of
readonly
CONTENT_DISPOSITION = 'form-data'.freeze.
Instance Method Summary collapse
- #create_request_headers(zipfile, slug)
- #update_mime_headers(zipfile)
- #update_request_headers(stream, boundary)
Instance Attribute Details
#on_behalf_of (readonly)
CONTENT_DISPOSITION = 'form-data'.freeze
11 12 13 |
# File 'lib/stash/sword/header_utils.rb', line 11 def on_behalf_of @on_behalf_of end |
Instance Method Details
#create_request_headers(zipfile, slug)
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stash/sword/header_utils.rb', line 13 def create_request_headers(zipfile, slug) { 'Content-Type' => APPLICATION_ZIP, 'Content-Disposition' => "#{CONTENT_DISPOSITION}; filename=#{File.basename(zipfile)}", 'Packaging' => SIMPLE_ZIP, 'Content-MD5' => Digest::MD5.file(zipfile).to_s, 'On-Behalf-Of' => on_behalf_of, 'Slug' => slug } end |
#update_mime_headers(zipfile)
33 34 35 36 37 38 39 40 41 |
# File 'lib/stash/sword/header_utils.rb', line 33 def update_mime_headers(zipfile) { 'Content-Type' => APPLICATION_ZIP, 'Content-Disposition' => "#{CONTENT_DISPOSITION}; name=\"payload\"; filename=\"#{File.basename(zipfile)}\"", 'Packaging' => SIMPLE_ZIP, 'Content-MD5' => Digest::MD5.file(zipfile).to_s, 'MIME-Version' => '1.0' } end |
#update_request_headers(stream, boundary)
24 25 26 27 28 29 30 31 |
# File 'lib/stash/sword/header_utils.rb', line 24 def update_request_headers(stream, boundary) { 'Content-Length' => stream.size.to_s, 'Content-Type' => "#{MULTIPART_RELATED_ATOM_XML}; boundary=\"#{boundary}\"", 'On-Behalf-Of' => on_behalf_of, 'MIME-Version' => '1.0' } end |