예제 #1
0
        public PostRequestData(string data)
        {
            MapImpl m_params = new MapImpl();

            var pairs = data.Split('&');

            foreach (var pair in pairs)
            {
                var nameVal = pair.Split(new Char[] { '=' }, 2);
                if (nameVal.Length == 2)
                {
                    IValue key = ValueFactory.Create(Decode(nameVal[0]));
                    IValue val = ValueFactory.Create(Decode(nameVal[1]));
                    m_params.Insert(key, val);
                }
                else if (pair.Length > 0)
                {
                    IValue val = ValueFactory.Create(Decode(pair));
                    m_params.Insert(val, ValueFactory.Create());
                }

                _params = new FixedMapImpl(m_params);
                _files  = new FixedMapImpl(new MapImpl());
            }
        }
예제 #2
0
        public HTTPServiceRequestImpl(System.Web.HttpContext ctx)
        {
            _httpContext = ctx;
            // Инициализируем объект для 1С
            // Заголовки
            MapImpl headers = new MapImpl();

            for (int i = 0; i < _httpContext.Request.Headers.Count; i++)
            {
                headers.Insert(ValueFactory.Create(_httpContext.Request.Headers.GetKey(i))
                               , ValueFactory.Create(_httpContext.Request.Headers.Get(i))
                               );
            }

            this._headers = new FixedMapImpl(headers);

            // ПараметрыURL будут пустыми
            _urlParams = new FixedMapImpl(new MapImpl());

            // Параметры запроса
            MapImpl queryOptions = new MapImpl();

            for (int i = 0; i < _httpContext.Request.Params.Count; i++)
            {
                queryOptions.Insert(ValueFactory.Create(_httpContext.Request.Params.GetKey(i))
                                    , ValueFactory.Create(_httpContext.Request.Params.Get(i))
                                    );
            }

            _queryOptions = new FixedMapImpl(queryOptions);

            _context = new HTTPServiceContextImpl(_httpContext);
        }
예제 #3
0
        private void UpdateHeaders()
        {
            var mapHdrs = new MapImpl();

            foreach (var realObjectHeader in _realObject.Headers)
            {
                mapHdrs.SetIndexedValue(ValueFactory.Create(realObjectHeader.Key), ValueFactory.Create(realObjectHeader.Value));
            }
            Headers = new FixedMapImpl(mapHdrs);
        }
예제 #4
0
        public HttpRequestImpl(HttpRequest request)
        {
            _realObject = request;
            var mapHdrs = new MapImpl();

            foreach (var realObjectHeader in _realObject.Headers)
            {
                mapHdrs.SetIndexedValue(ValueFactory.Create(realObjectHeader.Key), ValueFactory.Create(realObjectHeader.Value));
            }
            Headers = new FixedMapImpl(mapHdrs);
        }
예제 #5
0
        private void FillEnvironmentVars()
        {
            MapImpl vars = new MapImpl();

            foreach (DictionaryEntry item in Environment.GetEnvironmentVariables())
            {
                vars.Insert(
                    ValueFactory.Create((string)item.Key),
                    ValueFactory.Create((string)item.Value));
            }

            _environmentVars = new FixedMapImpl(vars);
        }
예제 #6
0
        private void UpdateCookies()
        {
            var cookieMap = new MapImpl();

            if (_realObject.Cookies != null)
            {
                foreach (var cookie in _realObject.Cookies)
                {
                    cookieMap.SetIndexedValue(ValueFactory.Create(cookie.Key),
                                              ValueFactory.Create(cookie.Value));
                }
            }

            Cookies = new FixedMapImpl(cookieMap);
        }
예제 #7
0
        public HTTPServiceRequestImpl(System.Web.HttpContext ctx)
        {
            _httpContext = ctx;
            // Инициализируем объект для 1С
            // Заголовки
            MapImpl headers = new MapImpl();

            for (int i = 0; i < _httpContext.Request.Headers.Count; i++)
            {
                headers.Insert(ValueFactory.Create(_httpContext.Request.Headers.GetKey(i))
                               , ValueFactory.Create(_httpContext.Request.Headers.Get(i))
                               );
            }

            this._headers = new FixedMapImpl(headers);

            // ПараметрыURL будут пустыми
            _urlParams = new FixedMapImpl(new MapImpl());

            // Параметры запроса
            MapImpl queryOptions = new MapImpl();

            // Изменено для совместимости. в 1С только параметры командной строки
            // Надо перенести в Контекст
            //for (int i = 0; i < _httpContext.Request.Params.Count; i++)
            //    queryOptions.Insert(ValueFactory.Create(_httpContext.Request.Params.GetKey(i))
            //                       , ValueFactory.Create(_httpContext.Request.Params.Get(i))
            //                       );
            for (int i = 0; i < _httpContext.Request.QueryString.Count; i++)
            {
                queryOptions.Insert(ValueFactory.Create(_httpContext.Request.QueryString.GetKey(i))
                                    , ValueFactory.Create(_httpContext.Request.QueryString.Get(i))
                                    );
            }

            _queryOptions = new FixedMapImpl(queryOptions);

            _context = new HTTPServiceContextImpl(_httpContext);
        }
예제 #8
0
        public PostRequestData(byte [] buffer, string boundary)
        {
            using (var stdin = new MemoryStream(buffer))
            {
                var     parser   = new MultipartFormDataParser(stdin, boundary, Encoding.UTF8);
                MapImpl m_params = new MapImpl();
                foreach (var param in parser.Parameters)
                {
                    m_params.Insert(ValueFactory.Create(param.Name), ValueFactory.Create(param.Data));
                }
                _params = new FixedMapImpl(m_params);

                MapImpl m_files = new MapImpl();
                foreach (var file in parser.Files)
                {
                    m_files.Insert(
                        ValueFactory.Create(file.Name),
                        ValueFactory.Create(new PostFileDescription(file))
                        );
                }
                _files = new FixedMapImpl(m_files);
            }
        }