コード例 #1
0
ファイル: Interop.winhttp.cs プロジェクト: z77ma/runtime
 public static partial bool WinHttpQueryHeaders(
     SafeWinHttpHandle requestHandle,
     uint infoLevel,
     string name,
     ref uint number,
     ref uint bufferLength,
     IntPtr index);
コード例 #2
0
ファイル: Interop.winhttp.cs プロジェクト: z77ma/runtime
        public static extern bool WinHttpAddRequestHeaders(
            SafeWinHttpHandle requestHandle,
#pragma warning disable CA1838 // Uses pooled StringBuilder
            [In] StringBuilder headers,
#pragma warning restore CA1838
            uint headersLength,
            uint modifiers);
コード例 #3
0
ファイル: Interop.winhttp.cs プロジェクト: z77ma/runtime
 public static partial bool WinHttpSetCredentials(
     SafeWinHttpHandle requestHandle,
     uint authTargets,
     uint authScheme,
     string? userName,
     string? password,
     IntPtr reserved);
コード例 #4
0
 public static extern bool WinHttpQueryHeaders(
     SafeWinHttpHandle requestHandle,
     uint infoLevel,
     string name,
     [Out] StringBuilder buffer,
     ref uint bufferLength,
     ref uint index);
コード例 #5
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpSendRequest(
     SafeWinHttpHandle requestHandle,
     [In] StringBuilder headers,
     uint headersLength,
     IntPtr optional,
     uint optionalLength,
     uint totalLength,
     IntPtr context);
コード例 #6
0
 public static void DisposeAndClearHandle(ref SafeWinHttpHandle handle)
 {
     if (handle != null)
     {
         handle.Dispose();
         handle = null;
     }
 }
コード例 #7
0
 public static extern SafeWinHttpHandle WinHttpOpenRequest(
     SafeWinHttpHandle connectHandle,
     string verb,
     string objectName,
     string version,
     string referrer,
     string acceptTypes,
     uint flags);
コード例 #8
0
 public static void DisposeAndClearHandle(ref SafeWinHttpHandle safeHandle)
 {
     if (safeHandle != null)
     {
         safeHandle.Dispose();
         safeHandle = null;
     }
 }
コード例 #9
0
        public static extern bool WinHttpQueryHeaders(
#endif
            SafeWinHttpHandle requestHandle,
            uint infoLevel,
            string name,
            IntPtr buffer,
            ref uint bufferLength,
            ref uint index);
コード例 #10
0
 public static void DisposeAndClearHandle(ref SafeWinHttpHandle winHttpHandler)
 {
     if (winHttpHandler != null)
     {
         winHttpHandler.Dispose();
         winHttpHandler = null;
     }
 }
コード例 #11
0
 public static partial bool WinHttpSendRequest(
     SafeWinHttpHandle requestHandle,
     IntPtr headers,
     uint headersLength,
     IntPtr optional,
     uint optionalLength,
     uint totalLength,
     IntPtr context);
コード例 #12
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern SafeWinHttpHandleWithCallback WinHttpOpenRequestWithCallback(
     SafeWinHttpHandle connectHandle,
     string verb,
     string objectName,
     string version,
     string referrer,
     string acceptTypes,
     uint flags);
コード例 #13
0
 public static extern bool WinHttpSendRequest(
     SafeWinHttpHandle requestHandle,
     [In] StringBuilder headers,
     uint headersLength,
     IntPtr optional,
     uint optionalLength,
     uint totalLength,
     IntPtr context);
コード例 #14
0
 public static void DisposeAndClearHandle(ref SafeWinHttpHandle handle)
 {
     if (handle != null)
     {
         handle.Dispose();
         handle = null;
     }
 }
コード例 #15
0
 public static void DisposeAndClearHandle(ref SafeWinHttpHandle safeHandle)
 {
     if (safeHandle != null)
     {
         safeHandle.Dispose();
         safeHandle = null;
     }
 }
コード例 #16
0
            // Important: WinHttp API calls should not happen while another WinHttp call for the same handle did not
            // return. During finalization that was not initiated by the Dispose pattern we don't expect any other WinHttp
            // calls in progress.
            protected override bool ReleaseHandle()
            {
                if (_parentHandle != null)
                {
                    _parentHandle.DangerousRelease();
                    _parentHandle = null;
                }

                return(Interop.WinHttp.WinHttpCloseHandle(handle));
            }
コード例 #17
0
            // Important: WinHttp API calls should not happen while another WinHttp call for the same handle did not
            // return. During finalization that was not initiated by the Dispose pattern we don't expect any other WinHttp
            // calls in progress.
            protected override bool ReleaseHandle()
            {
                if (_parentHandle != null)
                {
                    _parentHandle.DangerousRelease();
                    _parentHandle = null;
                }

                // TODO(Issue 2500): Add logging so we know when the handle gets closed.
                return(Interop.WinHttp.WinHttpCloseHandle(handle));
            }
コード例 #18
0
 // Important: WinHttp API calls should not happen while another WinHttp call for the same handle did not 
 // return. During finalization that was not initiated by the Dispose pattern we don't expect any other WinHttp
 // calls in progress.
 protected override bool ReleaseHandle()
 {
     if (_parentHandle != null)
     {
         _parentHandle.DangerousRelease();
         _parentHandle = null;
     }
     
     // TODO(Issue 2500): Add logging so we know when the handle gets closed.
     return Interop.WinHttp.WinHttpCloseHandle(handle);
 }
コード例 #19
0
            public void SetParentHandle(SafeWinHttpHandle parentHandle)
            {
                Debug.Assert(_parentHandle == null);
                Debug.Assert(parentHandle != null);
                Debug.Assert(!parentHandle.IsInvalid);

                bool ignore = false;
                parentHandle.DangerousAddRef(ref ignore);
                
                _parentHandle = parentHandle;
            }
コード例 #20
0
            public void SetParentHandle(SafeWinHttpHandle parentHandle)
            {
                Debug.Assert(_parentHandle == null);
                Debug.Assert(parentHandle != null);
                Debug.Assert(!parentHandle.IsInvalid);

                bool ignore = false;

                parentHandle.DangerousAddRef(ref ignore);

                _parentHandle = parentHandle;
            }
コード例 #21
0
        private uint CalculateHeaderBufferSize(SafeWinHttpHandle hRequest)
        {
            uint bufferLengthInBytes = 0;
            uint index = 0;

            if (!WinHttpQueryHeaders(
                    hRequest,
                    WINHTTP_QUERY_RAW_HEADERS_CRLF,
                    WINHTTP_HEADER_NAME_BY_INDEX,
                    IntPtr.Zero,
                    ref bufferLengthInBytes,
                    ref index) && Marshal.GetLastWin32Error() == ERROR_INSUFFICIENT_BUFFER)
            {
                return(bufferLengthInBytes);
            }
            return(0);
        }
コード例 #22
0
        private string GetHeaders(SafeWinHttpHandle hRequest, uint bufferLengthInBytes)
        {
            uint index = 0;
            var  pBuf  = Marshal.AllocHGlobal((int)bufferLengthInBytes);

            if (!WinHttpQueryHeaders(
                    hRequest,
                    WINHTTP_QUERY_RAW_HEADERS_CRLF,
                    WINHTTP_HEADER_NAME_BY_INDEX,
                    pBuf,
                    ref bufferLengthInBytes,
                    ref index))
            {
                throw new IOException("Unable to read headers: " + Marshal.GetLastWin32Error());
            }
            Log.Debug("Header len after read: " + bufferLengthInBytes);
            var header = Marshal.PtrToStringAuto(pBuf);

            Marshal.FreeHGlobal(pBuf);
            return(header);
        }
コード例 #23
0
        public WinHttpSession(
            Uri responseUri,
            SafeWinHttpHandle hConnect,
            SafeWinHttpHandle hRequest,
            Dictionary <string, List <string> >?headers,
            Dictionary <string, string>?cookies,
            byte[]?postData = null)
        {
            this.responseUri = responseUri;
            this.hConnect    = hConnect;
            this.hRequest    = hRequest;
            this.callback    = new(WinHttpCallback);
            IntPtr oldCallback = WinHttpSetStatusCallback(
                hRequest,
                this.callback,
                WINHTTP_CALLBACK_FLAG_REDIRECT,
                IntPtr.Zero);

            if (oldCallback == new IntPtr(WINHTTP_INVALID_STATUS_CALLBACK))
            {
                int lastError = Marshal.GetLastWin32Error();
                if (lastError != ERROR_INVALID_HANDLE) // Ignore error if handle was already closed.
                {
                    throw new IOException(nameof(WinHttpSetStatusCallback));
                }
            }
            this.headers = headers;
            this.cookies = cookies;
            if (postData != null && postData.Length > 0)
            {
                this.postData = Marshal.AllocHGlobal(postData.Length);
                Marshal.Copy(postData, 0, this.postData.Value, postData.Length);
                this.postDataSize = postData.Length;
            }
            this.responseStream = new WinHttpResponseStream(this.hRequest);
        }
コード例 #24
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern SafeWinHttpHandleWithCallback WinHttpConnectWithCallback(
     SafeWinHttpHandle sessionHandle,
     string serverName,
     ushort serverPort,
     uint reserved);
コード例 #25
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryOption(
     SafeWinHttpHandle handle,
     uint option,
     IntPtr buffer,
     ref uint bufferSize);
コード例 #26
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern uint WinHttpWebSocketClose(
     SafeWinHttpHandle webSocketHandle,
     ushort status,
     IntPtr reason,
     uint reasonLength);
コード例 #27
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern uint WinHttpWebSocketQueryCloseStatus(
     SafeWinHttpHandle webSocketHandle,
     out ushort status,
     byte[] reason,
     uint reasonLength,
     out uint reasonLengthConsumed);
コード例 #28
0
 public static extern bool WinHttpSetOption(
     SafeWinHttpHandle handle,
     uint option,
     IntPtr optionData,
     uint optionLength);
コード例 #29
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern uint WinHttpWebSocketShutdown(
     SafeWinHttpHandle webSocketHandle,
     ushort status,
     byte[] reason,
     uint reasonLength);
コード例 #30
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpWriteData(
     SafeWinHttpHandle requestHandle,
     IntPtr buffer,
     uint bufferSize,
     IntPtr parameterIgnoredAndShouldBeNullForAsync);
コード例 #31
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpReceiveResponse(
     SafeWinHttpHandle requestHandle,
     IntPtr reserved);
コード例 #32
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpReadData(
     SafeWinHttpHandle requestHandle,
     IntPtr buffer,
     uint bufferSize,
     out uint bytesRead);
コード例 #33
0
 public static extern bool WinHttpQueryDataAvailable(
     SafeWinHttpHandle requestHandle,
     IntPtr parameterIgnoredAndShouldBeNullForAsync);
コード例 #34
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryHeaders(
     SafeWinHttpHandle requestHandle,
     uint infoLevel,
     string name,
     [Out] StringBuilder buffer,
     ref uint bufferLength,
     ref uint index);
コード例 #35
0
 public static extern IntPtr WinHttpSetStatusCallback(
     SafeWinHttpHandle handle,
     WINHTTP_STATUS_CALLBACK callback,
     uint notificationFlags,
     IntPtr reserved);
コード例 #36
0
 public static extern bool WinHttpSetTimeouts(
     SafeWinHttpHandle handle,
     int resolveTimeout,
     int connectTimeout,
     int sendTimeout,
     int receiveTimeout);
コード例 #37
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpAddRequestHeaders(
     SafeWinHttpHandle requestHandle,
     string headers,
     uint headersLength,
     uint modifiers);
コード例 #38
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpWriteData(
     SafeWinHttpHandle requestHandle,
     IntPtr buffer,
     uint bufferSize,
     out uint bytesWritten);
コード例 #39
0
 public static extern bool WinHttpQueryDataAvailable(
     SafeWinHttpHandle requestHandle,
     out uint bytesAvailable);
コード例 #40
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryOption(
     SafeWinHttpHandle handle,
     uint option,
     [Out] StringBuilder buffer,
     ref uint bufferSize);
コード例 #41
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryDataAvailable(
     SafeWinHttpHandle requestHandle,
     out uint bytesAvailable);
コード例 #42
0
 public static extern bool WinHttpQueryOption(
     SafeWinHttpHandle handle,
     uint option,
     ref uint buffer,
     ref uint bufferSize);
コード例 #43
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern uint WinHttpWebSocketSend(
     SafeWinHttpHandle webSocketHandle,
     WINHTTP_WEB_SOCKET_BUFFER_TYPE bufferType,
     IntPtr buffer,
     uint bufferLength);
コード例 #44
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern uint WinHttpWebSocketReceive(
     SafeWinHttpHandle webSocketHandle,
     IntPtr buffer,
     uint bufferLength,
     out uint bytesRead,
     out WINHTTP_WEB_SOCKET_BUFFER_TYPE bufferType);
コード例 #45
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpSetOption(
     SafeWinHttpHandle handle,
     uint option,
     ref uint optionData,
     uint optionLength = sizeof(uint));
コード例 #46
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryHeaders(
     SafeWinHttpHandle requestHandle,
     uint infoLevel,
     string name,
     ref uint number,
     ref uint bufferLength,
     IntPtr index);
コード例 #47
0
 public static extern bool WinHttpSetOption(
     SafeWinHttpHandle handle,
     uint option,
     ref uint optionData,
     uint optionLength = sizeof(uint));
コード例 #48
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpSetOption(
     SafeWinHttpHandle handle,
     uint option,
     IntPtr optionData,
     uint optionLength);
コード例 #49
0
 public static extern bool WinHttpQueryAuthSchemes(
     SafeWinHttpHandle requestHandle,
     out uint supportedSchemes,
     out uint firstScheme,
     out uint authTarget);
コード例 #50
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpSetCredentials(
     SafeWinHttpHandle requestHandle,
     uint authTargets,
     uint authScheme,
     string userName,
     string password,
     IntPtr reserved);
コード例 #51
0
 public static extern bool WinHttpGetProxyForUrl(
     SafeWinHttpHandle sessionHandle, string url,
     ref WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions,
     out WINHTTP_PROXY_INFO proxyInfo);
コード例 #52
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpQueryAuthSchemes(
     SafeWinHttpHandle requestHandle,
     out uint supportedSchemes,
     out uint firstScheme,
     out uint authTarget);
コード例 #53
0
 public static extern SafeWinHttpHandle WinHttpConnect(
     SafeWinHttpHandle sessionHandle,
     string serverName,
     ushort serverPort,
     uint reserved);
コード例 #54
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpSetTimeouts(
     SafeWinHttpHandle handle,
     int resolveTimeout,
     int connectTimeout,
     int sendTimeout,
     int receiveTimeout);
コード例 #55
0
 public static extern bool WinHttpAddRequestHeaders(
     SafeWinHttpHandle requestHandle,
     string headers,
     uint headersLength,
     uint modifiers);
コード例 #56
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern bool WinHttpGetProxyForUrl(
     SafeWinHttpHandle sessionHandle, string url,
     ref WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions,
     out WINHTTP_PROXY_INFO proxyInfo);
コード例 #57
0
 public static extern bool WinHttpReceiveResponse(
     SafeWinHttpHandle requestHandle,
     IntPtr reserved);
コード例 #58
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern IntPtr WinHttpSetStatusCallback(
     SafeWinHttpHandle handle,
     WINHTTP_STATUS_CALLBACK callback,
     uint notificationFlags,
     IntPtr reserved);
コード例 #59
0
 public static extern bool WinHttpReadData(
     SafeWinHttpHandle requestHandle,
     IntPtr buffer,
     uint bufferSize,
     IntPtr parameterIgnoredAndShouldBeNullForAsync);
コード例 #60
0
ファイル: Interop.winhttp.cs プロジェクト: noahfalk/corefx
 public static extern SafeWinHttpHandleWithCallback WinHttpWebSocketCompleteUpgrade(
     SafeWinHttpHandle requestHandle,
     IntPtr context);