Hi.
I'm not sure what's the exactly problem here but I think it has something to do with the Encoding. I've used Firefox and the .NET Framework built-in HttpRequestMessage and both tell me that the Content-Length for this form data is 7 but Chilkat will make 9 out of it. Probably because of the "%20" space encoding. But if I send 9 to the server, he will reject the request.
static void Main(string[] args)
{
// Set up some things
const string logFileName = "log.txt";
var url = new Uri("http://www.example.net/");
var formData = new Dictionary<string, string>
{
["space"] = " ",
};
// .NET Framework
var request = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = new FormUrlEncodedContent(formData)
};
File.AppendAllText(logFileName, $"Content-Length: {request.Content.Headers.ContentLength}");
// Chilkat
var http = new Http {SessionLogFilename = logFileName};
http.UnlockComponent("test");
var chilkatRequest = new HttpRequest
{
HttpVerb = "POST",
ContentType= "application/x-www-form-urlencoded"
};
foreach (var pair in formData)
{
chilkatRequest.AddParam(pair.Key, pair.Value);
}
var response = http.SynchronousRequest(url.Host, 80, false, chilkatRequest);
// See both results
Process.Start(logFileName);
}
Thanks in advance.