public void Send(
Version httpVersion,
Dictionary<string, string> httpHeader,
byte[] httpBodyData,
HttpMethod httpMethod,
int timeOut)
{
this.httpWebRequest = (HttpWebRequest)WebRequest.Create(this.httpUri);
this.httpWebRequest.Timeout = timeOut;
this.httpWebRequest.Method = httpMethod.ToString();
if (userName != null)
{
this.httpWebRequest.Credentials = new NetworkCredential(userName, userPassword, domainName);
}
// The default version of HTTP to use for the request is HTTP 1.1.
if (HttpVersion.Version10 == httpVersion)
{
this.httpWebRequest.ProtocolVersion = HttpVersion.Version10;
}
if (this.logger != null)
{
this.logger.AddDebug(string.Format(
@"The HTTP WEB request is created:
The requested HTTP URI is:{0}, the HTTP method used:{1}, tshe HTTP version used:{2}",
this.httpUri.ToString(),
httpMethod.ToString(),
this.httpWebRequest.ProtocolVersion.ToString()));
}
if (httpHeader != null)
{
foreach (string key in httpHeader.Keys)
{
this.httpWebRequest.Headers.Add(key, httpHeader[key]);
}
}
if (httpMethod != HttpMethod.GET && httpBodyData != null)
{
this.httpWebRequest.ContentLength = httpBodyData.Length;
try
{
this.httpBodyStream = this.httpWebRequest.GetRequestStream();
this.httpBodyStream.Write(httpBodyData, 0, httpBodyData.Length);
this.httpBodyStream.Close();
}
catch (ObjectDisposedException e)
{
if (this.logger != null)
{
this.logger.AddDebug(
string.Format("Object disposed exception is catched, detailed information: {0}.", e.Message));
}
throw;
}
}
if (this.logger != null)
{
this.logger.AddInfo("The HTTP full content request is created and sent successfully.");
}
}