本文介绍了HttpWebRequest CONNECT方法 - 连接后写入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我已使用HttpWebRequest通过代理成功连接到远程服务器,并将Method属性设置为"CONNECT"。但是,只有在连接后才能从流中读取数据,这使连接变得无用,因为我无法与作为CONNECT目标的服务器进行交互。 示例代码: I have successfully connected to a remote server through a proxy using HttpWebRequest with the Method property set to "CONNECT". However it only seems possible to read data from the stream once connected, making the connection useless since I can't interact with the server that was the target of the CONNECT.Sample code: HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://remote.server.name:999");request.Method = WebRequestMethods.Http.Connect;request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;HttpWebResponse response = (HttpWebResponse)request.GetResponse();Stream stream = response.GetResponseStream();byte[] input = new byte[10240];stream.Read(input, 0, input.Length);byte[] output = GetData();// I would like to be able to do the following, but a NotSupportedException is thrown (Message: "The stream does not support writing.")stream.Write(output, 0, output.Length); 推荐答案 这篇关于HttpWebRequest CONNECT方法 - 连接后写入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 00:00