mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-31 04:58:07 +00:00
Update OpenURI.open_uri handling of headers
This commit is contained in:
parent
d846aaa159
commit
525e943370
@ -33,11 +33,14 @@ class GitHubRawIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
||||
end
|
||||
|
||||
begin
|
||||
OpenURI.open_uri(
|
||||
uri,
|
||||
headers = {
|
||||
'Header' => 'application/vnd.github+json',
|
||||
'X-GitHub-Api-Version' => '2022-11-28'
|
||||
) do |f|
|
||||
'X-GitHub-Api-Version' => '2022-11-28',
|
||||
}
|
||||
|
||||
headers['Authorization'] = "Token #{ENV['GITHUB_API_BEARER_TOKEN']}" if ENV['GITHUB_API_BEARER_TOKEN']
|
||||
|
||||
OpenURI.open_uri(uri, headers) do |f|
|
||||
response = JSON.parse(f.read)
|
||||
|
||||
# If the response is an array, it is likely to be a directory. In this
|
||||
|
@ -45,12 +45,11 @@ class GitLabRawIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
||||
query = { :ref => rev }
|
||||
uri.query = URI.encode_www_form query
|
||||
|
||||
begin
|
||||
OpenURI.open_uri(
|
||||
uri,
|
||||
'Content-Type' => 'application/json',
|
||||
'PRIVATE-TOKEN' => ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN'],
|
||||
) do |f|
|
||||
content = begin
|
||||
headers = { 'Content-Type' => 'application-json' }
|
||||
header['PRIVATE-TOKEN'] = ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN'] if ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN']
|
||||
|
||||
OpenURI.open_uri(uri, headers) do |f|
|
||||
response = JSON.parse(f.read)
|
||||
|
||||
if response['content'] && response['encoding'] == 'base64'
|
||||
|
Loading…
Reference in New Issue
Block a user