Note that there are some explanatory texts on larger screens.

plurals
  1. POReading a Stream object without consuming it
    primarykey
    data
    text
    <p>I'm using XML-RPC.NET (from <a href="http://www.xml-rpc.net/" rel="nofollow">http://www.xml-rpc.net/</a>) and the HttpListener method of listening for XML-RPC communication on a specific network port and responding to it.</p> <p>The body of a request that comes in is accessible through the <code>HttpListenerContextInstance.Request.InputStream</code> Stream object:</p> <pre><code>HttpListener hlListener = new HttpListener(); HttpListenerContext hlcContext = hlListener.GetContext(); // hlcContext.Request.InputStream contains what I want </code></pre> <p>The Stream can be accessed from <code>hlcContext.Request.InputStream</code> but this Stream is not seekable so I can't read it/display it and then seek back to the beginning of it so that the XML-RPC.NET library can use it as it needs to. Once it's read, it's consumed and can't be re-read.</p> <p>I understand that one way of handling this situation would be to convert it from a Stream into a MemoryStream which does support seeking, however, I don't know of a way to do this so that XML-RPC.NET continues on using the MemoryStream instead of the Stream. Just copying the Stream to a MemoryStream seems to consume the Stream making it unusable past that point:</p> <pre><code>// hlcContext.Request.InputStream is currently filled MemoryStream msInput = new MemoryStream(); hlcContext.Request.InputStream.CopyTo(msInput); byte[] byteInput = msInput.ToArray(); // hlcContext.Request.InputStream is now empty and XML-RPC.NET can no longer use it :( </code></pre> <p>How can I read from the Stream so that I can store it in a String and have the Stream continue to work with XML-RPC.NET after that point?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload