예제 #1
0
        public static CFHTTPMessage CreateRequest(Uri uri, string method, Version version)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            CFUrl    urlRef    = null;
            NSString methodRef = null;

            var escaped = Uri.EscapeUriString(uri.ToString());

            try {
                urlRef = CFUrl.FromUrlString(escaped, null);
                if (urlRef == null)
                {
                    throw new ArgumentException("Invalid URL.");
                }
                methodRef = new NSString(method);

                return(CreateRequest(urlRef, methodRef, version));
            } finally {
                if (urlRef != null)
                {
                    urlRef.Dispose();
                }
                if (methodRef != null)
                {
                    methodRef.Dispose();
                }
            }
        }
예제 #2
0
        public static CFHTTPMessage CreateRequest(Uri uri, string method, Version version)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            CFUrl    urlRef    = null;
            NSString methodRef = null;

            // the method is obsolete, but EscapeDataString does not work the same way. We could get the components
            // of the Uri and then EscapeDataString, but this might introduce bugs, so for now we will ignore the warning
#pragma warning disable SYSLIB0013
            var escaped = Uri.EscapeUriString(uri.ToString());
#pragma warning restore SYSLIB0013

            try {
                urlRef = CFUrl.FromUrlString(escaped, null);
                if (urlRef == null)
                {
                    throw new ArgumentException("Invalid URL.");
                }
                methodRef = new NSString(method);

                return(CreateRequest(urlRef, methodRef, version));
            } finally {
                if (urlRef != null)
                {
                    urlRef.Dispose();
                }
                if (methodRef != null)
                {
                    methodRef.Dispose();
                }
            }
        }