|
|
@ -74,24 +74,31 @@ namespace NzbDrone.Core.Providers.Core
|
|
|
|
|
|
|
|
|
|
|
|
byte[] byteArray = Encoding.ASCII.GetBytes(command);
|
|
|
|
byte[] byteArray = Encoding.ASCII.GetBytes(command);
|
|
|
|
|
|
|
|
|
|
|
|
var request = WebRequest.Create(address);
|
|
|
|
var request = (HttpWebRequest)WebRequest.Create(address);
|
|
|
|
request.Method = "POST";
|
|
|
|
request.Method = "POST";
|
|
|
|
request.Credentials = new NetworkCredential(username, password);
|
|
|
|
request.Credentials = new NetworkCredential(username, password);
|
|
|
|
request.ContentLength = byteArray.Length;
|
|
|
|
request.ContentType = "application/json";
|
|
|
|
request.ContentType = "application/x-www-form-urlencoded";
|
|
|
|
request.Timeout = 2000;
|
|
|
|
var dataStream = request.GetRequestStream();
|
|
|
|
request.KeepAlive = false;
|
|
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
|
|
|
|
|
|
dataStream.Close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var response = request.GetResponse();
|
|
|
|
//Used to hold the JSON response
|
|
|
|
dataStream = response.GetResponseStream();
|
|
|
|
string responseFromServer;
|
|
|
|
var reader = new StreamReader(dataStream);
|
|
|
|
|
|
|
|
// Read the content.
|
|
|
|
using (var requestStream = request.GetRequestStream())
|
|
|
|
string responseFromServer = reader.ReadToEnd();
|
|
|
|
{
|
|
|
|
|
|
|
|
requestStream.Write(byteArray, 0, byteArray.Length);
|
|
|
|
|
|
|
|
|
|
|
|
reader.Close();
|
|
|
|
using (var response = request.GetResponse())
|
|
|
|
dataStream.Close();
|
|
|
|
{
|
|
|
|
response.Close();
|
|
|
|
using (var responseStream = response.GetResponseStream())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (var reader = new StreamReader(responseStream))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
responseFromServer = reader.ReadToEnd();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return responseFromServer.Replace(" ", " ");
|
|
|
|
return responseFromServer.Replace(" ", " ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|