예제 #1
0
        public static string Info(this UnityWebRequest request)
        {
            var builder = new StringBuilder();

            builder.Append("Request URL: ");
            builder.Append(request.url);
            builder.Append("\nRequest Method: ");
            builder.Append(request.method);
            builder.Append("\nStatus Code: ");
            builder.Append(request.responseCode);
            if (request.GetRequestHeader("Cookie") != null)
            {
                builder.Append("\nCookies\n---------------\n");
                builder.Append(request.GetRequestHeader("Cookie").Replace(' ', '\n'));
                builder.Append("---------------");
            }
            if (request.GetResponseHeaders() != null)
            {
                builder.Append("\nResponse Headers\n---------------");
                foreach (var pair in request.GetResponseHeaders())
                {
                    builder.Append("\n");
                    builder.Append(pair.Key);
                    builder.Append(": ");
                    builder.Append(pair.Value);
                }
                builder.Append("\n---------------");
            }
            if (request.GetResponseBody() != null)
            {
                builder.Append("\nResponse body:");
                builder.Append(request.GetResponseBody());
            }
            builder.Append("\n---------------");
            return(builder.ToString());
        }