Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

In below code I am Logging the http call details
a. URL address
b. Response code
c. Size of package
d. Call duration

Now I want to add iterative requests if more files are included and need to be downloaded.Can anyone please help with code?


VB
Public Function NavigateTo(uriString As String) As Response
       Dim resp As New Response
       Dim request As HttpWebRequest = CType(WebRequest.Create(uriString), HttpWebRequest)
       Dim startTime, endTime As Date

       request.MaximumAutomaticRedirections = 4
       request.MaximumResponseHeadersLength = 4

       request.Credentials = CredentialCache.DefaultCredentials

       startTime = Date.Now()

       Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)

       endTime = Date.Now()

       Dim receiveStream As Stream = response.GetResponseStream()

       Dim readStream As New StreamReader(receiveStream, Encoding.UTF8)

       resp.StrResponse = readStream.ReadToEnd()
       resp.ResponseCode = Integer.Parse(response.StatusCode).ToString()
       resp.Size = response.ContentLength.ToString()
       resp.Time = endTime.Subtract(startTime).TotalMilliseconds.ToString()

       response.Close()
       readStream.Close()

       Return resp
   End Function
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900