1 Star 0 Fork 0

github__fork/CefSharp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
FlashResourceHandler.cs 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
amaitland 提交于 2019-06-21 10:07 +08:00 . ResourceHandler - Add new methods and callbacks
// Copyright © 2016 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using System.IO;
using System.Net;
using System.Threading.Tasks;
namespace CefSharp.Example
{
public class FlashResourceHandler : ResourceHandler
{
public override CefReturnValue ProcessRequestAsync(IRequest request, ICallback callback)
{
Task.Run(() =>
{
using (callback)
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://samples.mplayerhq.hu/SWF/zeldaADPCM5bit.swf");
var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
// Get the stream associated with the response.
var receiveStream = httpWebResponse.GetResponseStream();
var mime = httpWebResponse.ContentType;
var stream = new MemoryStream();
receiveStream.CopyTo(stream);
httpWebResponse.Close();
//Reset the stream position to 0 so the stream can be copied into the underlying unmanaged buffer
stream.Position = 0;
//Populate the response values - No longer need to implement GetResponseHeaders (unless you need to perform a redirect)
ResponseLength = stream.Length;
MimeType = mime;
StatusCode = (int)HttpStatusCode.OK;
Stream = stream;
callback.Continue();
}
});
return CefReturnValue.ContinueAsync;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/github__fork/CefSharp.git
git@gitee.com:github__fork/CefSharp.git
github__fork
CefSharp
CefSharp
master

搜索帮助