Esempio n. 1
0
 public GSResponse(String method, string responseText, GSLogger logSoFar) :
     this(method, new Dictionary <string, string>(), responseText, logSoFar)
 {
 }
Esempio n. 2
0
        public GSResponse(String method, Dictionary <string, string> headers, string responseText, GSLogger logSoFar)
        {
            logger.Write(logSoFar);
            this.headers      = headers;
            this.responseText = responseText.Trim();

            if (responseText == null || responseText.Length == 0)
            {
                return;
            }
            else
            {
                logger.Write("response", responseText);
            }

            if (responseText.StartsWith("{")) // JSON format
            {
                try
                {
                    this.data         = new GSObject(responseText);
                    this.errorCode    = data.GetInt("errorCode", 0);
                    this.errorMessage = data.GetString("errorMessage", null);
                }
                catch (Exception ex)
                {
                    this.errorCode    = 500;
                    this.errorMessage = ex.Message;
                }
            }
            else
            {
                // using string search to avoid dependency on parser
                String errCodeStr = GetStringBetween(responseText, "<errorCode>", "</errorCode>");
                if (errCodeStr != null)
                {
                    this.errorCode    = int.Parse(errCodeStr);
                    this.errorMessage = GetStringBetween(responseText, "<errorMessage>", "</errorMessage>");
                }
                //initializing the data with XML transformed to GSObject
                this.data = XmlToJSON(responseText);
            }
        }
Esempio n. 3
0
 public GSResponse(String method, GSObject clientParams, int errorCode, String errorMessage, GSLogger logSoFar) :
     this(method, GetErrorResponseText(method, clientParams, errorCode, errorMessage ?? GetErrorMessage(errorCode)), logSoFar)
 {
 }