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

            this.parameters[name] = parameter;
        }
예제 #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]);
        }
예제 #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));
        }
예제 #4
0
        public HttpHeader(string key, string value)
        {
            CoreValidator.ThrowIfNullOrEmty(key, nameof(key));
            CoreValidator.ThrowIfNullOrEmty(value, nameof(value));

            this.Key   = key;
            this.Value = value;
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #8
0
        public object GetParameter(string name)
        {
            CoreValidator.ThrowIfNullOrEmty(name, nameof(name));

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

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

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

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