Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
set the Content-Type to application/json when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Muller committed Aug 19, 2011
1 parent bf3628e commit db76b1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/logglier/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.new(input_url, opts={})
unless input_url
raise URLRequired.new
end

opts.merge!({ :input_url => input_url })

begin
Expand All @@ -33,7 +33,7 @@ def self.new(input_url, opts={})
else
raise Logglier::UnsupportedScheme.new("#{input_uri.scheme} is unsupported")
end

end

module InstanceMethods
Expand Down
7 changes: 6 additions & 1 deletion lib/logglier/client/http/sync.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def initialize(input_uri, opts={})
@ca_file = opts[:ca_file]
@read_timeout = opts[:read_timeout] || 5
@open_timeout = opts[:open_timeout] || 5
@format = opts[:format] ? opts[:format].to_sym : nil
@headers = {}
if @format == :json
@headers['Content-Type'] = 'application/json'
end

connect!
end
Expand All @@ -29,7 +34,7 @@ def initialize(input_uri, opts={})
def deliver(message)
retried = false
begin
@http.request_post(@input_uri.path, message)
@http.request_post(@input_uri.path, message, @headers)
# We're using persistent connections, so connection can be closed by the other side
# after a timeout. Don't consider it an error, just retry once.
rescue Errno::ECONNRESET
Expand Down

0 comments on commit db76b1a

Please sign in to comment.