Exemplo n.º 1
0
        protected override IWebResponse GetResponse(ref string address, string function)
        {
            ValidateAddress(address);

            if (alternateResponse != null)
            {
                return(new BasicResponse(alternateResponse.GetResponseText(ref address)));
            }
            else
            {
                return(base.GetResponse(ref address, function));
            }
        }
Exemplo n.º 2
0
        public Task <HttpResponseMessage> GetSync(string address)
        {
            var statusCode = GetStatusCode();

            var message = new HttpResponseMessage(statusCode)
            {
                Content        = new StringContent(response.GetResponseText(ref address)),
                RequestMessage = new HttpRequestMessage()
                {
                    RequestUri = new Uri(address)
                }
            };

            SetContentHeaders(message);

            return(Task.FromResult(message));
        }
Exemplo n.º 3
0
        public Task <HttpResponseMessage> GetSync(string address, CancellationToken token)
        {
            var statusCode = GetStatusCode();

            if (token.IsCancellationRequested)
            {
                throw new TaskCanceledException();
            }

            var message = new HttpResponseMessage(statusCode)
            {
                Content        = new StringContent(response.GetResponseText(ref address)),
                RequestMessage = new HttpRequestMessage()
                {
                    RequestUri = new Uri(address)
                }
            };

            SetContentHeaders(message);

            return(Task.FromResult(message));
        }
        public string GetResponseText(ref string address)
        {
            var func = MultiTypeResponse.GetFunctionEnum(address);

            if (func.Equals(CommandFunction.AddSensor2))
            {
                return("<div class=\"errormsg\"><p>PRTG Network Monitor has discovered a problem. Your last request could not be processed properly.</p><h3>Error message: Sorry, a read-only user account is not allowed to access this web page.</h3><small style=\"padding:5px;text-align:left\">Url: /controls/addsensor2.htm<br>Params: id=2055&sensortype=exexml&username=prtguser&passhash=***&</small></div>");
            }

            var htmlFunc = func as HtmlFunction?;

            var response = normalResponse.GetResponseText(ref address);

            if (htmlFunc != null)
            {
                return(CleanResponse(response));
            }

            return(response);
        }
Exemplo n.º 5
0
        public string GetResponseText(ref string address)
        {
            var func = MultiTypeResponse.GetFunctionEnum(address);

            if (func.Equals(CommandFunction.AddSensor2))
            {
                return(string.Empty);
            }

            var htmlFunc = func as HtmlFunction?;

            var response = normalResponse.GetResponseText(ref address);

            if (htmlFunc != null)
            {
                return(CleanResponse(response));
            }

            return(response);
        }
Exemplo n.º 6
0
 public string DownloadString(string address)
 {
     return(response.GetResponseText(address));
 }