Module: PoliPage::Internal::PresignedFetch Private
- Included in:
- Client
- Defined in:
- lib/poli_page/internal/presigned_fetch.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Mixin used by ‘PoliPage::Client` for the unauthenticated presigned-URL second hop (DocumentDescriptor#download_pdf, render.pdf, pdf_stream). The presigned URL is signed by S3 and MUST NOT be retried by the SDK (sdk-ruby-plan.md §5.5).
Honors the same proxy/CA configuration as Transport — reads ‘@proxy`, `@ca_file`, `@ca_path`, `@timeout` from the including `Client` instance.
Instance Method Summary collapse
-
#fetch_bytes(url) ⇒ Object
private
Fetch the entire body of ‘url`.
-
#stream_bytes(url, &block) ⇒ Object
private
Stream the body of ‘url` to the block.
Instance Method Details
#fetch_bytes(url) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fetch the entire body of ‘url`. Returns the raw bytes; raises PoliPage::DownloadError on non-2xx or network failure.
22 23 24 25 26 27 28 29 |
# File 'lib/poli_page/internal/presigned_fetch.rb', line 22 def fetch_bytes(url) uri = URI.parse(url) response = start_presigned(uri) { |http| http.request(Net::HTTP::Get.new(uri.request_uri)) } guard_presigned_status!(response) response.body rescue *PRESIGNED_NETWORK_ERRORS => e raise PoliPage::DownloadError.new(message: e.) end |
#stream_bytes(url, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Stream the body of ‘url` to the block. Raises PoliPage::DownloadError on non-2xx and PoliPage::InternalError on Content-Length: 0 (port of Node `render.ts:128-130` `!response.body` guard).
34 35 36 37 38 39 40 41 |
# File 'lib/poli_page/internal/presigned_fetch.rb', line 34 def stream_bytes(url, &block) uri = URI.parse(url) start_presigned(uri) do |http| http.request_get(uri.request_uri) { |response| yield_stream_chunks(response, &block) } end rescue *PRESIGNED_NETWORK_ERRORS => e raise PoliPage::DownloadError.new(message: e.) end |