Esempio n. 1
0
        public static NSJSObject New(NSJSVirtualMachine machine, NSJSObject context, HTTPResponse response)
        {
            if (machine == null || context == null || response == null)
            {
                return(null);
            }
            NSJSObject objective = NSJSObject.New(machine);

            objective.Set("CurrentContext", context);
            objective.DefineProperty("ContentEncoding", g_ContentEncodingProc, g_ContentEncodingProc);
            objective.DefineProperty("ContentType", g_ContentTypeProc, g_ContentTypeProc);
            objective.DefineProperty("StatusDescription", g_StatusDescriptionProc, g_StatusDescriptionProc);
            objective.DefineProperty("StatusCode", g_StatusCodeProc, g_StatusCodeProc);
            objective.DefineProperty("KeepAlive", g_KeepAliveProc, g_KeepAliveProc);
            objective.DefineProperty("ProtocolVersion", g_ProtocolVersionProc, g_ProtocolVersionProc);
            objective.DefineProperty("RedirectLocation", g_RedirectLocationProc, g_RedirectLocationProc);
            objective.DefineProperty("SendChunked", g_SendChunkedProc, g_SendChunkedProc);
            objective.DefineProperty("Headers", g_HeadersProc, g_HeadersProc);
            objective.DefineProperty("Cookies", g_CookiesProc, g_CookiesProc);

            objective.Set("Redirect", g_RedirectProc);
            objective.Set("End", g_EndProc);
            objective.Set("Abort", g_AbortProc);

            objective.Set("SetCookie", g_SetCookieProc);
            objective.Set("AppendCookie", g_SetCookieProc);
            objective.Set("AddHeader", g_AddHeaderProc);
            objective.Set("AppendHeader", g_AddHeaderProc);

            objective.Set("Write", g_WriteProc);
            objective.Set("WriteFile", g_WriteFileProc);
            objective.Set("BinaryWrite", g_BinaryWriteProc);
            NSJSKeyValueCollection.Set(objective, response);
            return(objective);
        }
Esempio n. 2
0
        private static void ContentEncoding(IntPtr info)
        {
            NSJSFunctionCallbackInfo arguments = NSJSFunctionCallbackInfo.From(info);
            HTTPResponse             response  = GetResponse(arguments.This);

            if (response == null)
            {
                Throwable.ObjectDisposedException(arguments.VirtualMachine);
            }
            else
            {
                NSJSVirtualMachine machine = arguments.VirtualMachine;
                if (arguments.Length <= 0)
                {
                    arguments.SetReturnValue(NSJSEncoding.New(machine, response.ContentEncoding));
                }
                else
                {
                    var encoding = NSJSEncoding.GetEncoding(arguments[0] as NSJSObject);
                    if (encoding == null)
                    {
                        encoding = NSJSEncoding.DefaultEncoding;
                    }
                    response.ContentEncoding = encoding;
                    arguments.SetReturnValue(true);
                }
            }
        }