improve post_chunk_body method: get rid of initial 401 error and fix Accepted Language header
This commit is contained in:
parent
097bb265e3
commit
f611c8545f
@ -30,7 +30,8 @@ module HttpUtils
|
||||
h = (json ? self.headers : self.headers("Content-Type", "Accept"))
|
||||
submit do |http|
|
||||
buf = ""
|
||||
resp = http.post(create_url(path), body, h) do |chunk|
|
||||
http.force_basic_auth = true
|
||||
resp = http.post(create_url(path), body: body, header: h) do |chunk|
|
||||
puts chunk
|
||||
buf = chunk
|
||||
end
|
||||
@ -126,7 +127,7 @@ module HttpUtils
|
||||
"Content-Type" => "application/json; charset=UTF-8"
|
||||
}
|
||||
|
||||
h["Accept-Language"] = I18n.lang
|
||||
h["Accept-Language"] = I18n.locale
|
||||
exclude.each do |key|
|
||||
h.delete(key)
|
||||
end
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
module I18n
|
||||
|
||||
@@lang = {}
|
||||
@@locale = ''
|
||||
|
||||
def self.language= locale
|
||||
@locale = locale
|
||||
spec = Gem::Specification.find_by_name(DevopsClient::NAME)
|
||||
gem_root = spec.gem_dir
|
||||
path = File.join(gem_root, "locales", "#{locale}.yml")
|
||||
@ -51,4 +53,8 @@ module I18n
|
||||
@@lang
|
||||
end
|
||||
|
||||
def self.locale
|
||||
@locale
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user