Skip to content

Commit

Permalink
fix casing of headers
Browse files Browse the repository at this point in the history
in rack headers are prefixed with HTTP_, upper cased and dashes are replaced with underscores
when reading response headers and setting response headers, headers are lower cased and dashes are used
  • Loading branch information
nvdk committed Jun 25, 2018
1 parent 620f0d2 commit 46ee3a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions sinatra_template/sparql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class Client < ::SPARQL::Client
# @return [Net::HTTPResponse]
# @see http://www.w3.org/TR/sparql11-protocol/#query-operation
def request(query, headers = {}, &block)
headers['MU_SESSION_ID'] = RequestStore.store[:mu_session_id]
headers['MU_CALL_ID'] = RequestStore.store[:mu_call_id]
headers['MU_AUTH_ALLOWED_GROUPS'] = RequestStore.store[:mu_auth_allowed_groups]
headers['MU_AUTH_USED_GROUPS'] = RequestStore.store[:mu_auth_used_groups]
headers['mu-session-id'] = RequestStore.store[:mu_session_id]
headers['mu-call-id'] = RequestStore.store[:mu_call_id]
headers['mu-auth-allowed-groups'] = RequestStore.store[:mu_auth_allowed_groups]
headers['mu-auth-used-groups'] = RequestStore.store[:mu_auth_used_groups]
response = super
RequestStore.store[:mu_auth_allowed_groups] = response['MU_AUTH_ALLOWED_GROUPS']
RequestStore.store[:mu_auth_used_groups] = response['MU_AUTH_USED_GROUPS']
RequestStore.store[:mu_auth_allowed_groups] = response['mu-auth-allowed-groups']
RequestStore.store[:mu_auth_used_groups] = response['mu-auth-used=groups']
response
end
end
Expand Down
8 changes: 4 additions & 4 deletions web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# Helpers
###
helpers SinatraTemplate::Helpers

use RequestStore::Middleware

###
# Hooks
Expand All @@ -61,18 +61,18 @@
RequestStore.store[:mu_auth_allowed_groups] = request.env['HTTP_MU_AUTH_ALLOWED_GROUPS']
RequestStore.store[:mu_auth_used_groups] = request.env['HTTP_MU_AUTH_USED_GROUPS']
end
rescue e
rescue Exception => e
log.error e
end
end

after do
auth_headers = {}
if RequestStore.store[:mu_auth_allowed_groups]
auth_headers['MU_AUTH_ALLOWED_GROUPS'] = RequestStore.store[:mu_auth_allowed_groups]
auth_headers['mu-auth-allowed-groups'] = RequestStore.store[:mu_auth_allowed_groups]
end
if RequestStore.store[:mu_auth_used_groups]
auth_headers['MU_AUTH_USED_GROUPS'] = RequestStore.store[:mu_auth_used_groups]
auth_headers['mu-auth-used-groups'] = RequestStore.store[:mu_auth_used_groups]
end
headers auth_headers
end
Expand Down

0 comments on commit 46ee3a9

Please sign in to comment.