Skip to content

fix: Split up the build_request function to logical component functions to reduce method complexity #67

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

Merged
merged 4 commits into from
Feb 21, 2020
Merged
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
Prev Previous commit
Next Next commit
Merge branch 'master' into method_complexity
  • Loading branch information
childish-sambino authored Feb 21, 2020
commit b269c309e6019a01496790129df39c9978067ae9
7 changes: 6 additions & 1 deletion lib/ruby_http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ def build_http_request(http_method)

def update_content_type(http_method)
if @request_body && content_type_json?
@request.body = @request_body.to_json
# If body is a hash, encode it; else leave it alone
@request.body = if @request_body.class == Hash
@request_body.to_json
else
@request_body
end
@request['Content-Type'] = 'application/json'
elsif !@request_body && http_method.to_s == 'post'
@request['Content-Type'] = ''
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.