8000 Update middleware.rb by blake41 · Pull Request #3 · mauricio/faraday_curl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update middleware.rb #3

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
12 changes: 6 additions & 6 deletions lib/faraday/curl/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def call(env)
end
end

if env[:body].respond_to?(:read)
if env[:truncated_body].respond_to?(:read)
command << "-d 'body is a stream, cant render it'"
elsif env[:body].respond_to?(:to_str)
command << "-d '#{quote(env[:body].to_str)}'"
elsif env[:body]
elsif env[:truncated_body].respond_to?(:to_str)
command << "-d '#{quote(env[:truncated_body].to_str)}'"
elsif env[:truncated_body]
command << "-d 'body is not string-like, cant render it'"
end

Expand All @@ -42,10 +42,10 @@ def call(env)
end

def quote(value)
value.gsub("'", "\\'")
value.gsub("'") { "\\'" }
end
end
end
end

Faraday::Request.register_middleware :curl => Faraday::Curl::Middleware
Faraday::Request.register_middleware :curl => Faraday::Curl::Middleware
0