Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.gem
.idea
6 changes: 3 additions & 3 deletions lib/pswincom/httpsender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module PSWinCom
class HttpSender
API_HOST = 'http://gw2-fro.pswin.com:81/'
API_HOST = 'http://xml.pswin.com/'

def initialize
@host = API.api_host || API_HOST
Expand All @@ -13,8 +13,8 @@ def initialize
def send request
url = URI.parse @host
post = Net::HTTP::Post.new(url.path)
post.body = request.xml.encode("ISO-8859-1")
post.content_type = 'text/xml charset=ISO-8859-1'
post.body = request.xml.encode('utf-8')
post.content_type = 'application/xml charset=utf-8'
Net::HTTP.start(url.host, url.port) {|http| http.request(post)}
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/httpsender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module PSWinCom
describe HttpSender do
describe "#initialize" do
it "uses default host" do
HttpSender.new.instance_variable_get(:@host).should == 'http://gw2-fro.pswin.com:81/'
# HttpSender.new.instance_variable_get(:@host).should == 'http://gw2-fro.pswin.com:81/'
expect(HttpSender.new.instance_variable_get(:@host)).to eq 'http://xml.pswin.com/'
end
it "uses custom host if specified" do
API.api_host = 'http://google.com/'
Expand All @@ -25,7 +26,8 @@ module PSWinCom
it "sends XML with correct content type" do
post = HttpSender.new.send(XmlMock.new("<xml>foo</xml>"))
post.body.should == "<xml>foo</xml>"
post.content_type.should == 'text/xml charset=ISO-8859-1'
# post.content_type.should == 'text/xml charset=ISO-8859-1'
expect(post.content_type).to eq 'application/xml charset=utf-8'
end
end
end
Expand Down