Click here to Skip to main content
Click here to Skip to main content

Building a Multithreaded-Socket WebServer using C#

By , 17 May 2013
 
bins.zip
bins
BizApplication.dll
ComunicationLayer.dll
Demos.dll
msdn_socketengine.dll
Newtonsoft.Json.dll
root
chat
background.jpg
Script
cornerlefttop.jpg
desk
background.jpg
Script
Server.dll
ServerCommonLibrary.dll
webserver.tester.exe
source.zip
source
source
CommonLibrary
0.ServerCommonLibrary.csproj.user
Properties
ComunicationLayer
Properties
Demos
Demos.csproj.user
lib
Newtonsoft.Json.dll
Properties
Settings.settings
MainBiz
Http
Properties
Settings.settings
Server
Properties
Settings.settings
Services
ServerTester
5.Tester.csproj.user
Properties
Settings.settings
root
chat
background.jpg
Script
cornerlefttop.jpg
desk
background.jpg
Script
SocketEngine
Properties
using System.Collections.Generic;
using ServerCommonLibrary;
using BizApplication.Http;

namespace BizApplication.http
{
   
    /// <summary>
    /// Contains server http request information
    /// </summary>
    public class HttpRequest : ApplicationRequest
    {

        protected HttpRequestType type;

        public HttpRequest(RawRequest request)
            : base(request)
        {
            type = HttpRequestType.HttpPage;
            Requests = new Dictionary<string, string>();
            UrlParameters = new Dictionary<string, string>();
        }

        //### Http Method Get/Post
        public HttpMethodType Method { get; set; }
        //### Http Type
        public HttpRequestType Type
        {
            get { return type; }
            set { type = value; }
        }

        //### Http Complete request ex: 
        public string CompleteRequest { get; set; }
        //### Request Full Path
        public string CompletePath { get; set; }
        //### Request Path
        public string Path { get; set; }
        //### Request Paths
        public IList<string> Paths { get; set; }
        //### Http Requests 
        public Dictionary<string, string> Requests;
        //### Query Url parameters
        public Dictionary<string, string> UrlParameters;        
        /// <summary>
        /// return true if Gzip compression is supported
        /// </summary>
        /// <returns></returns>
        public bool isGZIPSupported()
        {
            return (Requests != null && Requests.ContainsKey("Accept-Encoding") && Requests["Accept-Encoding"].Contains("gzip")) ? true : false;
        }
        /// <summary>
        /// Return query strin value, return "" if not exist
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetQueryStringValue(string key)
        {
            if (UrlParameters == null || UrlParameters.Count == 0 || !UrlParameters.ContainsKey(key)) return string.Empty;
            return UrlParameters[key];
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Alberto Biafelli
Software Developer
Italy Italy
Member
Alberto Biafelli,
Software Developer

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 17 May 2013
Article Copyright 2012 by Alberto Biafelli
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid