Subject: Problems when sending Latin characters using BOSH
I testing AGS BOSH feature and I have noticed the following:
if I send a message containing for example ààààààààà
an internal exception is thrown in method OnGetRequestStream
{"bytes to write in the stream exceed the size specified in Content-Length."} System.Exception {System.Net.ProtocolViolationException}
Actually the Content-Length is set as req.ContentLength = state.Output.Length;
while byte[] bytes = Encoding.UTF8.GetBytes(state.Output); returns array of bytes that is longer than the state.Output.Length !!!
Apparently this is due the character à which is encoded over 2 bytes
An immediate workaround is to add this in StartWebRequest()
byte[] bytes = Encoding.UTF8.GetBytes(state.Output);
req.ContentLength = bytes.Length;
if I send a message containing for example ààààààààà
an internal exception is thrown in method OnGetRequestStream
{"bytes to write in the stream exceed the size specified in Content-Length."} System.Exception {System.Net.ProtocolViolationException}
Actually the Content-Length is set as req.ContentLength = state.Output.Length;
while byte[] bytes = Encoding.UTF8.GetBytes(state.Output); returns array of bytes that is longer than the state.Output.Length !!!
Apparently this is due the character à which is encoded over 2 bytes
An immediate workaround is to add this in StartWebRequest()
byte[] bytes = Encoding.UTF8.GetBytes(state.Output);
req.ContentLength = bytes.Length;