Revellion wrote:
Thx alot
, i'am starting the work emmidiatly
, and sure i'll add a nice Version tag for my Client, and when i consider it stable and compatible i'll might throw it in the Contrib forum
There are a couple of things to watch out for. Like everyone else I make up the POST data like this:
Code:
string s = "username=" + userName
+ "&password=" + password
+ "&version=" + VER
+ "&data=" + payload
;
So far so good, but if you have any characters above 127, the url-encode that is about to happen to your data will make you end up with some funny characters, so before I get to here I run the payload through my own UrlEncode:
Code:
public static string UrlEncode(string s)
{
string[] reserved = {"?", "=", "&"};
string[] replacement = {"%22", "%3d", "%26"};
for (int i = 0; i < reserved.Length; i++)
s = s.Replace(reserved[i], replacement[i]);
return s;
}
and then I run the whole thing through:
Code:
public static byte[] StringToByte(string s)
{
Char[] cAry = s.ToCharArray();
byte[] byteAry = new byte[cAry.Length];
for (int i = 0; i < cAry.Length; i++)
byteAry[i] = (byte)(cAry[i] & 0xFF);
return byteAry;
}
At that point I have a url-encoded (my way) byte array (which is what my POST routine wants) that I write onto the .NET WebRequest output stream. No problems with funny characters.
In case it's not obvious, you must do a POST and not a GET. I screwed around with it for a couple of days trying to create a QueryString and make GET work. <sigh>
-- Rick