Request.InputStream 和 Request.Headers 在一起 - 或者 - 将文本与流组合在一起
我正在使用 SharpMimeTools 库使用多部分 MIME 消息解析器。
MIME 库期望接收一个从 Request.InputStream 获取的流。
但是,它期望流包含 Request.InputStream 中没有的标头信息。
为了进行测试,我将 Request.InputStream 写入文本文件,将 Request.Headers 写入字符串。我打开了文本文件,粘贴到标题中,一切都按预期进行。
如何将标头字符串添加到流的开头?
可以这样做吗?获取一个字符串并将其添加到流的开头。
如果这不是理想的方法,是否有办法获取已附加标头的 InputStream?
谢谢!
编辑:这是我用作参考的内容: http://blog.rueedlinger.ch/2009/01/net-c-and-soap-with-attachments/
由于他在开头省略了构造函数,所以我不确定该代码的来源在哪里溪流是。结果 httpStream 是我的 Request.Input 流,而 mimeStream 只是一个新的 MemoryStream。
实际的二进制追加是使用 TextReader 和 TextWriter 完成的。
考虑这个问题已经解决了。最后一次迭代是...
I am working with a multipart MIME message parser, using the SharpMimeTools library.
The MIME library is expecting to receive a stream, which it is getting from Request.InputStream.
However, it expects the stream to contain header information which is not in the Request.InputStream.
For testing, I wrote Request.InputStream to a text file, wrote Request.Headers to a string. I opened the text file, pasted in the headers and everything works as expected.
How can I add my header string to the beginning of my stream?
Is it possible to do this? To take a string and add it to the beginning of a stream.
If this is not a desired way to do it, is there a way to get the InputStream with the headers already appended?
Thanks!
Edit: This was the what I was using as a reference: http://blog.rueedlinger.ch/2009/01/net-c-and-soap-with-attachments/
Since he omitted the constructors @ the beginning, I wasn't sure where the source of the stream was. Turns out httpStream was my Request.Input stream and mimeStream was simply a new MemoryStream.
The actual binary append was done using a TextReader and TextWriter.
Consider this solved. The last iteration was it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经在原来的问题中发布了这个问题的答案。
I'd posted the answer to this question in my original question.