public async void Start(string szUrl, IInternetProtocolSink pOIProtSink, IInternetBindInfo pOIBindInfo, PI_FLAGS grfPI, int dwReserved) { var bytes = new byte[4096]; try { using (var ms = new MemoryStream()) using (var stream = await _protocol.GetStreamAsync(szUrl)) { while (true) { var n = await stream.ReadAsync(bytes, 0, bytes.Length); if (n == 0) { data = ms.ToArray(); readPos = 0; pOIProtSink.ReportData(BSCF.BSCF_DATAFULLYAVAILABLE, (uint)ms.Length, 0); pOIProtSink.ReportResult(NativeConstants.S_OK, 0, ""); break; } ms.Write(bytes, 0, n); } } } catch (Exception ex) { pOIProtSink.ReportResult(NativeConstants.E_FAIL, 0, ex.Message); } }
int IInternetProtocolEx.Start(string szUrl, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { return Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved); }
private int Start(string szUrl, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { ClearData(); currentProtocolSink = protocolSink; currentUrl = szUrl; BINDINFO bindInfoData = new BINDINFO(); bindInfoData.cbSize = (uint)Marshal.SizeOf(bindInfoData); bindInfo.GetBindInfo(out currentBindFlags, ref bindInfoData); if ((grfPI & PI_FLAGS.PI_FORCE_ASYNC) != 0) { PROTOCOLDATA protocolData = new PROTOCOLDATA(); protocolData.grfFlags = PI_FLAGS.PI_FORCE_ASYNC; protocolSink.Switch(ref protocolData); return NativeConstants.E_PENDING; } else { return DoBind(); } }
int IInternetProtocolEx.StartEx(IUri uri, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { string szUrl; if (uri.GetAbsoluteUri(out szUrl) != NativeConstants.S_OK) return NativeConstants.INET_E_INVALID_URL; return Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved); }
public async void Start(string szUrl, IInternetProtocolSink pOIProtSink, IInternetBindInfo pOIBindInfo, PI_FLAGS grfPI, int dwReserved) { var bytes = new byte[4096]; try { using (var ms = new MemoryStream()) using (var stream = await _protocol.GetStreamAsync(szUrl)) { while (true) { var n = await stream.ReadAsync(bytes, 0, bytes.Length); if (n == 0) { data = ms.ToArray(); readPos = 0; pOIProtSink.ReportData(BSCF.BSCF_DATAFULLYAVAILABLE, (uint)ms.Length, 0); pOIProtSink.ReportResult(NativeConstants.S_OK, 0, ""); break; } ms.Write(bytes, 0, n); } } } catch (Exception ex) { pOIProtSink.ReportResult(NativeConstants.E_FAIL, 0, ex.Message); } }
private int Start(string szUrl, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { ClearData(); currentProtocolSink = protocolSink; currentUrl = szUrl; BINDINFO bindInfoData = new BINDINFO(); bindInfoData.cbSize = (uint)Marshal.SizeOf(bindInfoData); bindInfo.GetBindInfo(out currentBindFlags, ref bindInfoData); if ((grfPI & PI_FLAGS.PI_FORCE_ASYNC) != 0) { PROTOCOLDATA protocolData = new PROTOCOLDATA(); protocolData.grfFlags = PI_FLAGS.PI_FORCE_ASYNC; protocolSink.Switch(ref protocolData); return(NativeConstants.E_PENDING); } else { return(DoBind()); } }
int IInternetProtocolEx.Start(string szUrl, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { return(Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved)); }
int IInternetProtocolEx.StartEx(IUri uri, IInternetProtocolSink protocolSink, IInternetBindInfo bindInfo, PI_FLAGS grfPI, uint dwReserved) { string szUrl; if (uri.GetAbsoluteUri(out szUrl) != NativeConstants.S_OK) { return(NativeConstants.INET_E_INVALID_URL); } return(Start(szUrl, protocolSink, bindInfo, grfPI, dwReserved)); }