@@ -62,7 +62,8 @@ function _user_agent()
6262end
6363
6464# Ensures that the given headers contain the required values.
65- function _ensure_headers! (h = HTTP. Headers ())
65+ function _ensure_headers (headers= nothing )
66+ h = isnothing (headers) ? HTTP. Headers () : copy (headers)
6667 _haskeyfold (h, " accept" ) || push! (h, " Accept" => " application/json" )
6768 _haskeyfold (h, " content-type" ) || push! (h, " Content-Type" => " application/json" )
6869 _haskeyfold (h, " user-agent" ) || push! (h, " User-Agent" => _user_agent ())
7172
7273function get_access_token (ctx:: Context , creds:: ClientCredentials ):: AccessToken
7374 url = _get_client_credentials_url (creds)
74- h = _ensure_headers! ()
75+ h = _ensure_headers ()
7576 body = """ {
7677 "client_id": $(repr (creds. client_id)) ,
7778 "client_secret": $(repr (creds. client_secret)) ,
@@ -181,7 +182,7 @@ function request(
181182 headers = h, query = nothing , body = b, kw...
182183):: HTTP.Response
183184 isnothing (body) && (body = UInt8[])
184- headers = _ensure_headers! (headers)
185+ headers = _ensure_headers (headers)
185186 _authenticate! (ctx, headers)
186187 opts = (;redirect = false , connection_limit = 4096 )
187188 return HTTP. request (method, url, headers; query = query, body = body, opts... , kw... )
0 commit comments