Beispiel #1
0
        public void AddParameter(string name, object parameter)
        {
            CoreValidator.ThrowIfNullOrEmty(name, nameof(name));
            CoreValidator.ThrowIfNull(parameter, nameof(parameter));

            this.parameters[name] = parameter;
        }
Beispiel #2
0
        public Func <IHttpRequest, IHttpResponse> Get(HttpRequestMethod requestMethod, string path)
        {
            CoreValidator.ThrowIfNull(requestMethod, nameof(requestMethod));
            CoreValidator.ThrowIfNullOrEmty(path, nameof(path));

            return(this.routes[requestMethod][path]);
        }
Beispiel #3
0
        public bool Contains(HttpRequestMethod requestMethod, string path)
        {
            CoreValidator.ThrowIfNull(requestMethod, nameof(requestMethod));
            CoreValidator.ThrowIfNullOrEmty(path, nameof(path));

            return(this.routes.ContainsKey(requestMethod) && this.routes[requestMethod].ContainsKey(path));
        }
Beispiel #4
0
        public HttpHeader(string key, string value)
        {
            CoreValidator.ThrowIfNullOrEmty(key, nameof(key));
            CoreValidator.ThrowIfNullOrEmty(value, nameof(value));

            this.Key   = key;
            this.Value = value;
        }
Beispiel #5
0
        public void Add(HttpRequestMethod method, string path, Func <IHttpRequest, IHttpResponse> func)
        {
            CoreValidator.ThrowIfNull(method, nameof(method));
            CoreValidator.ThrowIfNullOrEmty(path, nameof(path));
            CoreValidator.ThrowIfNull(func, nameof(func));

            this.routes[method].Add(path, func);
        }
Beispiel #6
0
        public HttpRequest(string requestString)
        {
            CoreValidator.ThrowIfNullOrEmty(requestString, nameof(requestString));

            this.FormData  = new Dictionary <string, object>();
            this.QueryData = new Dictionary <string, object>();
            this.Headers   = new HttpHeaderCollection();
            this.Cookies   = new HttpCookieCollection();

            this.ParseRequest(requestString);
        }
Beispiel #7
0
        public HttpCookie(string key, string value,
                          int expires = HttpCookieDefaultExpirationDays, string path = HttpCookieDefaultPath)
        {
            CoreValidator.ThrowIfNullOrEmty(key, nameof(key));
            CoreValidator.ThrowIfNullOrEmty(value, nameof(value));

            this.Key     = key;
            this.Value   = value;
            this.IsNew   = true;
            this.Path    = path;
            this.Expires = DateTime.UtcNow.AddDays(expires);
        }
Beispiel #8
0
        public object GetParameter(string name)
        {
            CoreValidator.ThrowIfNullOrEmty(name, nameof(name));

            return(this.parameters[name]);
        }
Beispiel #9
0
 public bool ContainsParameter(string name)
 {
     CoreValidator.ThrowIfNullOrEmty(name, nameof(name));
     return(this.parameters.ContainsKey(name));
 }
 public HttpHeader GetHeader(string key)
 {
     CoreValidator.ThrowIfNullOrEmty(key, nameof(key));
     return(this.httpHeaders[key]);
 }
 public bool ContainsHeader(string key)
 {
     CoreValidator.ThrowIfNullOrEmty(key, nameof(key));
     return(this.httpHeaders.ContainsKey(key));
 }
Beispiel #12
0
        private bool IsValidRequestQueryString(string queryString, string[] queryParameters)
        {
            CoreValidator.ThrowIfNullOrEmty(queryString, nameof(queryString));

            return(true);//TODO: RegEx querystring
        }
        public HttpCookie GetCookie(string key)
        {
            CoreValidator.ThrowIfNullOrEmty(key, nameof(key));

            return(this.httpCookies[key]);
        }
        public bool ContainsCookie(string key)
        {
            CoreValidator.ThrowIfNullOrEmty(key, nameof(key));

            return(this.httpCookies.ContainsKey(key));
        }