将 HttpRequest 发送回 HttpRequest(代理)
我有以下代码:
With context.Response
Dim req As HttpWebRequest = WebRequest.Create("http://www.Google.com/")
req.Proxy = Nothing
Dim res As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = res.GetResponseStream
.OutputStream.Write(Stream, 0, Stream.Length)
End With
遗憾的是,上面的代码不起作用。我需要获取 RequestStream 并将其从 context.Response 放入 OutputStream 中。
有什么想法吗?
I have the following code:
With context.Response
Dim req As HttpWebRequest = WebRequest.Create("http://www.Google.com/")
req.Proxy = Nothing
Dim res As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = res.GetResponseStream
.OutputStream.Write(Stream, 0, Stream.Length)
End With
Sadly, the above code doesn't work. I need to take the RequestStream and put it into the OutputStream from the context.Response.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Write 接受一个字节数组,而您向它传递一个流。
尝试从流中读取并获取所有数据,然后再将其写回。
首先,将数据读入中间字节数组(取自这里):
然后将其写入输出流:
Write takes a byte array, whereas you are passing it a stream.
Try reading from the stream and getting all the data before writing it back.
First, read the data into an intermediate byte array (Taken from here):
Then write it to the output stream: