Yanshof
Yanshof

Reputation: 9926

How to make a HttpWebRequest and sending Stream ( not sending byte[] )

When i using the HttpWebRequest - i need to send byte[] ( as far as i know ) So i doing it in this code

            _argRequest[] = .... 

            using( Stream reqStream = _httpWebRequest.GetRequestStream() )
            {
                if( _argRequest != null )
                {
                    reqStream.Write( _argRequest, 0, _argRequest.Length );
                    reqStream.Flush();
                    reqStream.Close();
                }
            }

But is it possible to send Stream and not byte[] - ( without casting the Stream to byte[] )

Thanks

Upvotes: 1

Views: 114

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100527

Stream.CopyTo can copy stream without (externally visible) usage of byte[]:

 streamToPost.CopyTo(reqStream);

Upvotes: 2

Related Questions