httpmodule通过httpfilter获取返回的网页内容
来源:互联网 发布:socket.io java服务端 编辑:程序博客网 时间:2024/05/22 08:17
自定义httpmodule里面:
public virtual void Init(HttpApplication app) { // WARNING! This does not work with Windows authentication! // If you are using Windows authentication, change to app.BeginRequest app.BeginRequest += (sender, e) => { app.Context.Response.Filter = new CatchTextStream(app.Response.Filter); }; }public class CatchTextStream : Stream
{
private Stream output;
public CatchTextStream(Stream s)
{
output = s;
}
public override bool CanRead
{
get { return output.CanRead; }
}
public override bool CanSeek
{
get { return output.CanSeek; }
}
public override bool CanWrite
{
get { return output.CanWrite; }
}
public override void Flush()
{
output.Flush();
}
public override long Length
{
get { return output.Length; }
}
public override long Position
{
get { return output.Position; }
set { output.Position = value; }
}
public override int Read(byte[] buffer, int offset, int count)
{
return output.Read(buffer, offset, count);
}
public override long Seek(long offset, SeekOrigin origin)
{
return output.Seek(offset, origin);
}
public override void SetLength(long value)
{
output.SetLength(value);
}
public override void Write(byte[] buffer, int offset, int count)
{
StringComparison ignore = StringComparison.CurrentCultureIgnoreCase;
if (HttpContext.Current != null)
{
HttpContext context = HttpContext.Current;
if (context.Response.ContentType.Equals("text/html", ignore))
{
Encoding encoding = context.Response.ContentEncoding;
//此处获取返回的HTML内容
string html = encoding.GetString(buffer, offset, count);
byte[] bytes = encoding.GetBytes(html);
output.Write(bytes, 0, bytes.Length);
else
output.Write(buffer, offset, count);
}
}
}
0 0
- httpmodule通过httpfilter获取返回的网页内容
- 通过socket 获取GET返回数据后的操作 分割报文头和网页内容
- 通过URL对象获取指定网页的内容
- php通过网页地址获取该地址下的内容
- PHP 通过curl库函数获取网页内容
- java通过url获取网页内容
- 关于CURL获取网页,返回的网页内容大小一直变化的原因
- 定义一个方法get_page(url),url参数是需要获取网页内容的网址,返回网页的内容
- php通过登录后的cookie以及用户代理然后通过curl获取网页内容
- U3D通过获取网页代码读取网页内容
- 获取html网页的内容
- 获取某一网页的内容
- 获取https网页的内容
- JAVA方法中通过调用URL来获取其返回的内容
- JAVA方法中通过调用URL来获取其返回的内容
- JAVA方法中通过调用URL来获取其返回的内容
- 通过URL返回请求的内容 C#
- 通过shell获取文件内容并返回给代码
- Angular JS中的then()
- RAR解密跑字典
- POJ 1068 Parencodings
- poj 1789 Truck History(kruskal算法)
- rwsem文件
- httpmodule通过httpfilter获取返回的网页内容
- hdu1878 欧拉回路(并查集)
- android 模拟按键
- android activity task 进程,线程综述
- linux echo 怎样输出转义字符?
- POJ3620 Avoid The Lakes
- 做事效率太低?你必须改掉这7种坏习惯
- C# 枚举进程模块
- java中PropertyDescriptor的使用简介