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"))
|
h = (json ? self.headers : self.headers("Content-Type", "Accept"))
|
||||||
submit do |http|
|
submit do |http|
|
||||||
buf = ""
|
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
|
puts chunk
|
||||||
buf = chunk
|
buf = chunk
|
||||||
end
|
end
|
||||||
@ -126,7 +127,7 @@ module HttpUtils
|
|||||||
"Content-Type" => "application/json; charset=UTF-8"
|
"Content-Type" => "application/json; charset=UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
h["Accept-Language"] = I18n.lang
|
h["Accept-Language"] = I18n.locale
|
||||||
exclude.each do |key|
|
exclude.each do |key|
|
||||||
h.delete(key)
|
h.delete(key)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
module I18n
|
module I18n
|
||||||
|
|
||||||
@@lang = {}
|
@@lang = {}
|
||||||
|
@@locale = ''
|
||||||
|
|
||||||
def self.language= locale
|
def self.language= locale
|
||||||
|
@locale = locale
|
||||||
spec = Gem::Specification.find_by_name(DevopsClient::NAME)
|
spec = Gem::Specification.find_by_name(DevopsClient::NAME)
|
||||||
gem_root = spec.gem_dir
|
gem_root = spec.gem_dir
|
||||||
path = File.join(gem_root, "locales", "#{locale}.yml")
|
path = File.join(gem_root, "locales", "#{locale}.yml")
|
||||||
@ -51,4 +53,8 @@ module I18n
|
|||||||
@@lang
|
@@lang
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.locale
|
||||||
|
@locale
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user