Exemplo n.º 1
0
 public static string MakeTempPath()
 {
     return(StringTools.Combine(Environment.GetEnvironmentVariable("TMP"), Guid.NewGuid().ToString("B")));
 }
Exemplo n.º 2
0
 public NamedEventPair()
     : this(StringTools.getUUID())
 {
 }
Exemplo n.º 3
0
 public static string GetTempPath(string relPath)
 {
     return(StringTools.Combine(Environment.GetEnvironmentVariable("TMP"), relPath));
 }
Exemplo n.º 4
0
        public HttpResponse Perform()
        {
            if (_version != HTTP_10)
            {
                if (_portNo == 80)
                {
                    this.SetHeaderField("Host", _domain);
                }
                else
                {
                    this.SetHeaderField("Host", _domain + ":" + _portNo);
                }
            }
            if (_body != null)
            {
                this.SetHeaderField("Content-Length", "" + _body.Length);
            }
            this.SetHeaderField("Connection", "close");

            if (_useIEProxy)
            {
                Uri proxy = WebRequest.GetSystemWebProxy().GetProxy(new Uri(this.GetUrl()));

                if (_domain != proxy.Host || _portNo != proxy.Port)
                {
                    _proxyDomain = proxy.Host;
                    _proxyPortNo = proxy.Port;
                }
            }
            using (TcpClient client = _proxyDomain == null ?
                                      new TcpClient(_domain, _portNo) :
                                      new TcpClient(_proxyDomain, _proxyPortNo)
                   )
            {
                client.SendTimeout    = _sendTimeoutMillis;
                client.ReceiveTimeout = _recvTimeoutMillis;

                using (NetworkStream ns = client.GetStream())
                {
                    if (_head)
                    {
                        Write(ns, "HEAD ");
                    }
                    else if (_body == null)
                    {
                        Write(ns, "GET ");
                    }
                    else
                    {
                        Write(ns, "POST ");
                    }
                    if (_proxyDomain == null)
                    {
                        Write(ns, _path);
                    }
                    else if (_proxyPortNo == 80)
                    {
                        Write(ns, "http://" + _domain + _path);
                    }
                    else
                    {
                        Write(ns, "http://" + _domain + ":" + _portNo + _path);
                    }
                    Write(ns, " ");
                    Write(ns, _version);
                    Write(ns, "\r\n");

                    foreach (string name in _headerFields.Keys)
                    {
                        String value = _headerFields[name];

                        if (value.Contains('\n'))
                        {
                            value = string.Join("\r\n\t", StringTools.Tokenize(value, "\r\n", false, true));
                        }

                        Write(ns, name);
                        Write(ns, ": ");
                        Write(ns, value);
                        Write(ns, "\r\n");
                    }
                    Write(ns, "\r\n");

                    if (_body != null)
                    {
                        Write(ns, _body);
                    }
                    return(new HttpResponse(ns, this.ResBodySizeMax, _head));
                }
            }
        }
Exemplo n.º 5
0
 public string MakePath()
 {
     return(StringTools.Combine(_rootDir, Guid.NewGuid().ToString("B")));
 }
Exemplo n.º 6
0
 public string GetPath(string relPath)
 {
     return(StringTools.Combine(_rootDir, relPath));
 }
Exemplo n.º 7
0
 public string makePath()
 {
     return(makePath(StringTools.getUUID()));
 }
Exemplo n.º 8
0
 public WorkingDir()
     : this(StringTools.getUUID())
 {
 }