mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-02-07 12:19:14 +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
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
OpenURI.open_uri(
|
headers = {
|
||||||
uri,
|
|
||||||
'Header' => 'application/vnd.github+json',
|
'Header' => 'application/vnd.github+json',
|
||||||
'X-GitHub-Api-Version' => '2022-11-28'
|
'X-GitHub-Api-Version' => '2022-11-28',
|
||||||
) do |f|
|
}
|
||||||
|
|
||||||
|
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)
|
response = JSON.parse(f.read)
|
||||||
|
|
||||||
# If the response is an array, it is likely to be a directory. In this
|
# 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 }
|
query = { :ref => rev }
|
||||||
uri.query = URI.encode_www_form query
|
uri.query = URI.encode_www_form query
|
||||||
|
|
||||||
begin
|
content = begin
|
||||||
OpenURI.open_uri(
|
headers = { 'Content-Type' => 'application-json' }
|
||||||
uri,
|
header['PRIVATE-TOKEN'] = ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN'] if ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN']
|
||||||
'Content-Type' => 'application/json',
|
|
||||||
'PRIVATE-TOKEN' => ENV['GITLAB_API_PERSONAL_ACCESS_TOKEN'],
|
OpenURI.open_uri(uri, headers) do |f|
|
||||||
) do |f|
|
|
||||||
response = JSON.parse(f.read)
|
response = JSON.parse(f.read)
|
||||||
|
|
||||||
if response['content'] && response['encoding'] == 'base64'
|
if response['content'] && response['encoding'] == 'base64'
|
||||||
|
Loading…
Reference in New Issue
Block a user