Пример #1
0
        /// <summary>
        /// Main entry point for all requests handled by this HTTP handler.
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            // Resolve request data
            string postData = new StreamReader(context.Request.InputStream).ReadToEnd();
            string requestUrl = context.Request.QueryString[_requestUrlParam];

            if (!string.IsNullOrEmpty(requestUrl))
            {
                // Forward request to IH Services instance
                var proxy = new ServiceProxy();
                var response = proxy.ForwardRequest(requestUrl, postData, context.Request.ContentType);

                // Return the response
                if (response.Content != null)
                {
                    if (response.Headers != null)
                    {
                        if (response.Content.Headers.ContentType != null)
                            context.Response.ContentType = response.Content.Headers.ContentType.ToString();

                        if (response.Content.Headers.ContentEncoding != null)
                            context.Response.AppendHeader("Content-Encoding", response.Content.Headers.ContentEncoding.ToString());
                    }

                    context.Response.BinaryWrite(response.Content.ReadAsByteArrayAsync().Result);
                }
            }
        }
Пример #2
0
        public void Test_Get_Public_Markup_For_Module_Instance()
        {
            _httpMessageHandler.Initialize(HttpStatusCode.OK, new StringContent(_publicMarkup));

            var proxy = new ServiceProxy(_requestContext);
            var moduleInstanceId = Guid.NewGuid().ToString();
            var results = proxy.GetModuleInstanceMarkup(moduleInstanceId);

            Assert.IsNotNullOrEmpty(results);
            Assert.IsTrue(results.Equals(_publicMarkup));
        }
Пример #3
0
        public void Test_Get_Module_Settings_Data()
        {
            _httpMessageHandler.Initialize(HttpStatusCode.OK, new StringContent(_moduleSettingsData));

            var proxy = new ServiceProxy(_requestContext);
            var results = proxy.GetContentAppSettingsData();

            dynamic settings = JsonConvert.DeserializeObject(results);

            Assert.AreEqual("-1", settings.LocationContextId.Value);
            Assert.AreEqual("/provider/{directurl}", settings.ProviderDetailPageUrl.Value);
        }
Пример #4
0
        public void Test_Get_Data_For_Module_Instance()
        {
            _httpMessageHandler.Initialize(HttpStatusCode.OK, new StringContent(_publicData));

            var proxy = new ServiceProxy(_requestContext);
            var moduleInstanceId = "be4502d7-796b-4878-9022-aa55cc6d2d0e";
            var results = proxy.GetModuleInstanceData(moduleInstanceId, null);

            dynamic data = JsonConvert.DeserializeObject(results);

            Assert.AreEqual(moduleInstanceId, data.ModuleInstanceId.Value);
            Assert.IsNotNullOrEmpty(data.ModuleName.Value);
        }