File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -26,13 +26,29 @@ def check
2626 end
2727end
2828
29+ class HeadCheck < OkComputer ::HttpCheck
30+ def perform_request
31+ Timeout . timeout ( request_timeout ) do
32+ options = { read_timeout : request_timeout }
33+
34+ if basic_auth_options . any?
35+ options [ :http_basic_authentication ] = basic_auth_options
36+ end
37+
38+ RestClient . head ( url . to_s , options )
39+ end
40+ rescue => e
41+ raise ConnectionFailed , e
42+ end
43+ end
44+
2945# Ensure Alma API is working.
30- OkComputer ::Registry . register 'alma-metadata' , OkComputer :: HttpCheck . new ( ALMA_TEST_URL )
46+ OkComputer ::Registry . register 'alma-metadata' , HeadCheck . new ( ALMA_TEST_URL )
3147
3248# Ensure TIND API is working. This cannot use `OkComputer::HttpCheck`
3349# out of the box as we can't yet inject headers into the request without
3450# subclassing the whole thing.
3551OkComputer ::Registry . register 'tind-metadata' , TindCheck . new
3652
3753# Ensure Wowza is working
38- OkComputer ::Registry . register 'wowza-streaming' , OkComputer :: HttpCheck . new ( WOWZA_TEST_URL )
54+ OkComputer ::Registry . register 'wowza-streaming' , HeadCheck . new ( WOWZA_TEST_URL )
Original file line number Diff line number Diff line change 22
33RSpec . describe 'OKComputer' , type : :request do
44 before do
5- stub_sru_request ( 'b23305522' )
5+ stub_sru_head_request ( 'b23305522' )
66
77 hls_manifest = File . read ( 'spec/data/playlist.m3u8' )
88 manifest_url = 'https://wowza.lib.berkeley.edu/Pacifica/mp3:PRA_NHPRC1_AZ1084_00_000_00.mp3/playlist.m3u8'
9- stub_request ( :get , manifest_url ) . to_return ( status : 200 , body : hls_manifest )
9+ stub_request ( :head , manifest_url ) . to_return ( status : 200 )
1010
1111 record_id = '(pacradio)01469'
1212 tind_url = BerkeleyLibrary ::AV ::Metadata ::Source ::TIND . marc_uri_for ( record_id )
Original file line number Diff line number Diff line change @@ -72,6 +72,11 @@ def stub_sru_request(record_id, body: nil)
7272 stub_request ( :get , sru_url ) . to_return ( status : 200 , body : body || File . new ( alma_sru_data_path_for ( record_id ) ) )
7373end
7474
75+ def stub_sru_head_request ( record_id , body : nil )
76+ sru_url = alma_sru_url_for ( record_id )
77+ stub_request ( :head , sru_url ) . to_return ( status : 200 )
78+ end
79+
7580def alma_marc_record_for ( record_id )
7681 marc_xml_path = alma_sru_data_path_for ( record_id )
7782 MARC ::XMLReader . new ( marc_xml_path ) . first
You can’t perform that action at this time.
0 commit comments