Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not showing binary request data by Content-Type for httpclient adapter #53

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/httplog/adapters/httpclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def do_get_block(req, proxy, conn, &block)
if log_enabled
HttpLog.log_request(req.header.request_method, req.header.request_uri)
HttpLog.log_headers(req.headers)
HttpLog.log_data(req.body)
HttpLog.log_data(req.body, req.headers['Content-Type'])
end

retryable_response = nil
Expand Down
6 changes: 5 additions & 1 deletion lib/httplog/http_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ def log_body(body, encoding = nil, content_type=nil)

end

def log_data(data)
def log_data(data, content_type = nil)
return if config.compact_log || !config.log_data
unless text_based?(content_type)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking all other adapters, since they're not passing in the request content type, and the default nil will not be treated as text based.

log("Data: (not showing binary data)")
return
end
data = utf_encoded(data.to_s.dup)

if config.prefix_data_lines
Expand Down