Request.InputStream 和 Request.Headers 在一起 - 或者 - 将文本与流组合在一起

发布于 2024-11-16 03:24:21 字数 732 浏览 2 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难以启齿的温柔 2024-11-23 03:24:21

我已经在原来的问题中发布了这个问题的答案。

I'd posted the answer to this question in my original question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文