HTTPFallback
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace Aspera.Transfer
{
public class HTTPFallback
{
private bool encodeAllAsJPEG;
private string httpsKeyFileName;
private string httpsCertFileName;
private int httpPort;
private EndPoint httpProxyAddress;
public HTTPFallback()
{
}
public HTTPFallback(int httpPort, bool encodeAllAsJPEG, string httpsKeyFileName, string httpsCertFileName, EndPoint httpProxyAddress)
{
if (httpsKeyFileName != null && !File.Exists(httpsKeyFileName))
throw new FaspManagerException("Key file path should refer to existing real path " + httpsKeyFileName);
if (httpsCertFileName != null && !File.Exists(httpsCertFileName))
throw new FaspManagerException("Certificate file path should refer to existing real path" + httpsCertFileName);
if (httpPort > 0)
this.httpPort = httpPort;
this.encodeAllAsJPEG = encodeAllAsJPEG;
this.httpsKeyFileName = httpsKeyFileName;
this.httpsCertFileName = httpsCertFileName;
this.httpProxyAddress = httpProxyAddress;
}
internal List<string> buildCommandOptions()
{
List<string> list = new List<string>();
list.Add("-y1");
if (encodeAllAsJPEG)
list.Add("-j1");
if (httpPort > 0) {
list.Add("-t");
list.Add(httpPort.ToString());
}
if (httpsKeyFileName != null) {
list.Add("-Y");
list.Add(httpsKeyFileName);
}
if (httpsCertFileName != null) {
list.Add("-I");
list.Add(httpsCertFileName);
}
if (httpProxyAddress != null) {
string text = null;
if (httpProxyAddress is DnsEndPoint) {
text = ((DnsEndPoint)httpProxyAddress).Host;
int port = ((DnsEndPoint)httpProxyAddress).Port;
if (port > 0)
text = text + ":" + port;
} else if (httpProxyAddress is IPEndPoint) {
text = ((IPEndPoint)httpProxyAddress).ToString();
}
if (text != null) {
list.Add("-x");
list.Add(text);
}
}
return list;
}
}
}