-
Notifications
You must be signed in to change notification settings - Fork 0
/
faraday_encoding.rb
27 lines (21 loc) · 910 Bytes
/
faraday_encoding.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'faraday'
require 'uri'
connection = Faraday.new do |c|
c.request :url_encoded
c.response :logger
c.adapter Faraday.default_adapter
end
connection.post do |request|
request.url 'http://localhost:3000/' # returns 200 OK when I use my Rails server
request.body = "From: \"Me\" <info@info.com>\nTo: \"You\" <info@info.com>\nHello"
end
puts "----------------------------------------------"
connection.post do |request|
request.url 'http://localhost:3000/' # returns 400 Bad Request when I use my Rails server
request.body = "From: \"Me\" <info@info.com>\nTo: \"You\" <info@info.com>\nHello %%"
end
puts "----------------------------------------------"
connection.post do |request|
request.url 'http://localhost:3000/' # returns 200 OK when I use my Rails server
request.body = URI.encode_www_form_component("From: \"Me\" <info@info.com>\nTo: \"You\" <info@info.com>\nHello %%")
end