From f137df7b8373cf1212c954f04a3149f5d8180788 Mon Sep 17 00:00:00 2001 From: Edward4j Date: Thu, 31 Aug 2017 11:49:46 +0300 Subject: [PATCH] Changed charachter encoding UTF-8 to the HttpSender --- .gitignore | 1 + lib/pswincom/httpsender.rb | 6 +++--- spec/httpsender_spec.rb | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c111b33..38a125e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.gem +.idea diff --git a/lib/pswincom/httpsender.rb b/lib/pswincom/httpsender.rb index 2dd25ee..3ad615d 100644 --- a/lib/pswincom/httpsender.rb +++ b/lib/pswincom/httpsender.rb @@ -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 @@ -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 diff --git a/spec/httpsender_spec.rb b/spec/httpsender_spec.rb index ea1da7b..a6fb94d 100644 --- a/spec/httpsender_spec.rb +++ b/spec/httpsender_spec.rb @@ -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/' @@ -25,7 +26,8 @@ module PSWinCom it "sends XML with correct content type" do post = HttpSender.new.send(XmlMock.new("foo")) post.body.should == "foo" - 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