* Changed XmlRpc to specify utf-8
parent
f7a938a21d
commit
8df2119bc7
|
@ -31,6 +31,7 @@ namespace Nwc.XmlRpc
|
|||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
|
||||
///<summary>Very basic HTTP request handler.</summary>
|
||||
///<remarks>This class is designed to accept a TcpClient and treat it as an HTTP request.
|
||||
|
@ -55,8 +56,10 @@ namespace Nwc.XmlRpc
|
|||
public SimpleHttpRequest(TcpClient client)
|
||||
{
|
||||
_client = client;
|
||||
_output = new StreamWriter(client.GetStream());
|
||||
_input = new StreamReader(client.GetStream());
|
||||
|
||||
_output = new StreamWriter(client.GetStream(), Encoding.UTF8 );
|
||||
_input = new StreamReader(client.GetStream(), Encoding.UTF8 );
|
||||
|
||||
GetRequestMethod();
|
||||
GetRequestHeaders();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Nwc.XmlRpc
|
|||
public class XmlRpcRequest
|
||||
{
|
||||
private String _methodName = null;
|
||||
private Encoding _encoding = new ASCIIEncoding();
|
||||
private Encoding _encoding = new UTF8Encoding();
|
||||
private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer();
|
||||
private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer();
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Nwc.XmlRpc
|
|||
using System;
|
||||
using System.Xml;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>The class is a container of the context of an XML-RPC dialog on the server side.</summary>
|
||||
/// <remarks>Instances of this class maintain the context for an individual XML-RPC server
|
||||
|
@ -98,8 +99,9 @@ namespace Nwc.XmlRpc
|
|||
if (Logger.Delegate != null)
|
||||
Logger.WriteEntry(xmlRpcResp.ToString(), LogLevel.Information);
|
||||
|
||||
XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
|
||||
XmlRpcServer.HttpHeader(httpReq.Protocol, "text/xml", 0, " 200 OK", httpReq.Output);
|
||||
httpReq.Output.Flush();
|
||||
|
||||
XmlTextWriter xml = new XmlTextWriter(httpReq.Output);
|
||||
_serializer.Serialize(xml, xmlRpcResp);
|
||||
xml.Flush();
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Nwc.XmlRpc
|
|||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>Base class of classes serializing data to XML-RPC's XML format.</summary>
|
||||
/// <remarks>This class handles the basic type conversions like Integer to <i4>. </remarks>
|
||||
|
@ -53,15 +54,22 @@ namespace Nwc.XmlRpc
|
|||
/// <seealso cref="XmlRpcRequest"/>
|
||||
public String Serialize(Object obj)
|
||||
{
|
||||
StringWriter strBuf = new StringWriter();
|
||||
XmlTextWriter xml = new XmlTextWriter(strBuf);
|
||||
xml.Formatting = Formatting.Indented;
|
||||
xml.Indentation = 4;
|
||||
Serialize(xml, obj);
|
||||
xml.Flush();
|
||||
String returns = strBuf.ToString();
|
||||
xml.Close();
|
||||
return returns;
|
||||
using (MemoryStream memStream = new MemoryStream(4096))
|
||||
{
|
||||
XmlTextWriter xml = new XmlTextWriter(memStream, Encoding.UTF8);
|
||||
xml.Formatting = Formatting.Indented;
|
||||
xml.Indentation = 4;
|
||||
Serialize(xml, obj);
|
||||
xml.Flush();
|
||||
|
||||
byte[] resultBytes = memStream.ToArray();
|
||||
|
||||
UTF8Encoding encoder = new UTF8Encoding();
|
||||
|
||||
String returns = encoder.GetString( resultBytes, 0, resultBytes.Length );
|
||||
xml.Close();
|
||||
return returns;
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>Serialize the object to the output stream.</remarks>
|
||||
|
|
Loading…
Reference in New Issue