Using HttpWebRequest to Post a byte array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Herring

    Using HttpWebRequest to Post a byte array

    I currently use httpwebrequest to download large byte array files from my
    server. I am curious about how to change my httpwebrequest code to allow
    posing a large byte array to a virtual foldeer. This is my download code
    which work well in
    returning a large byte array from the server:

    Function GetImageFromURL (ByVal url As String) As Byte()
    allDone.Reset()
    Try
    Dim wr As HttpWebRequest = DirectCast(WebR equest.Create(u rl), HttpWebRequest)
    If Not ProxyObject Is Nothing Then wr.Proxy = ProxyObject
    Dim MRS As New RequestState
    MRS.request = wr
    Dim result As IAsyncResult = CType(wr.BeginG etResponse(Addr essOf
    RespCallBack, MRS), IAsyncResult)
    allDone.WaitOne ()
    MRS.response.Cl ose()
    Return MRS.ReturnBLOB
    Catch MyException As Exception
    End Try
    End Function

    Private Sub RespCallBack(By Val asyncResult As IAsyncResult)
    Dim MRS As RequestState = CType(asyncResu lt.AsyncState, RequestState)
    Dim wr2 As HttpWebRequest = CType(MRS.reque st, HttpWebRequest)
    MRS.response = CType(wr2.EndGe tResponse(async Result), HttpWebResponse )
    Dim RS As Stream = MRS.response.Ge tResponseStream ()
    MRS.responseStr eam = RS
    Dim br As BinaryReader = New BinaryReader(MR S.responseStrea m)
    Dim bytesize As Long = MRS.response.Co ntentLength
    MRS.ReturnBLOB = br.ReadBytes(CI nt(bytesize))
    allDone.Set()
    End
Working...