コード例 #1
0
        unsafe internal static Byte[] marshall(HttpResp response, Object val,
                                               MediaType produces)
        {
            if (response.StatusCode == 0)
            {
                //which indicates that the user did not set this
                response.StatusCode = 200;
            }

            //return values can be Object, any built in Type, a file or nothing.
            //Process depending on return format specified by the user

            response.StatusDesc  = StatusCodeDesc.GetStatusDesc(response.StatusCode);
            response.ContentType = response.ContentType.Equals("") == true ?
                                   produces : response.ContentType;

            //package the body correctly
            Byte[] BodyContent = GetByte(val, produces);
            response.ContentLength = (UInt64)BodyContent.Length;

            HttpBody Body = response.Body;

            Body.SetLengthOfBody(BodyContent.Length);
            Body.SetBodyContent(BodyContent);
            return(response.Bytes());
        }
コード例 #2
0
        //public static AppSettings GetAppSettings () { return m_appSettings; }

        public static void createServer(RequestProcessor processor)
        {
            if (null == processor)
            {
                Program.processor = new RequestProcessor();
            }
            else
            {
                Program.processor = processor;
            }

            m_maxPayLoad = 1024; //Int32.Parse(ConfigMgr.AppSettings["maxPayLoad"]);
            StatusCodeDesc.init();
            HttpdServer.Transport.Socket sock = new HttpdServer.Transport.Socket("127.0.0.1", 15990);
            sock.StartListening();
        }
コード例 #3
0
        internal static byte[] DummyHookFunction(HttpRequest req)
        {
            if (null == defByte)
            {
                defByte = System.Text.Encoding.UTF8.GetBytes(def);
            }

            HttpResponse response = new HttpResponse();

            response.StatusDesc    = StatusCodeDesc.GetStatusDesc(200);
            response.ContentType   = MediaType.TEXT_PLAIN;
            response.ContentLength = (UInt64)defByte.Length;
            HttpBody body = response.Body;

            body.SetLengthOfBody(defByte.Length);
            body.SetBodyContent(defByte);
            return(response.Bytes());
        }