Results 1 to 2 of 2

Thread: [RESOLVED] downloading a file from HTTPS using proxy

  1. #1

    Thread Starter
    Junior Member praveenverma's Avatar
    Join Date
    Dec 2008
    Posts
    29

    Resolved [RESOLVED] downloading a file from HTTPS using proxy

    This was suppose to be a simple task,what i wanna do is download a file lets say https://www.onlinesubmit.in/people-computers.jpg but the original file has limited to view in a particular region so i have to use a proxy service and i am using https://www.proxy-service.de/

    so the complete link becomes https://www.proxy-service.de/proxy-s...&b=0&f=norefer

    now i have to download it by my app not via web-browser,

    when i try

    Code:
    Dim myclient As New WebClient
            Dim url As Uri = New Uri("https://www.onlinesubmit.in/people-computers.jpg")
            myclient.DownloadFileAsync(url, "pic.jpg")
    this works fine but if i change the Uri to https://www.proxy-service.de/proxy-s...&b=0&f=norefer this don't work as may be proxy site doesn't support hotlinking.

    so i google a bit and found some code which says i have to use
    Code:
    System.Net.WebProxy("http://proxy-service.de", True)
    for HTTP and
    Code:
    System.Net.WebProxy("proxy-service.https.de",443)
    for HTTPS

    so i try to write some code

    Code:
     Try
                Dim proxy As New System.Net.WebProxy("proxy-service.https.de", 443)
                proxy.Credentials = New System.Net.NetworkCredential("userId", "password", "Domain")
                Dim URI As String = "https://www.onlinesubmit.in/people-computers.jpg"
                Dim oRequest As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create(URI), System.Net.HttpWebRequest)
                oRequest.Proxy = proxy
                Using oResponse As System.Net.WebResponse = CType(oRequest.GetResponse, System.Net.WebResponse)
                    Using responseStream As IO.Stream = oResponse.GetResponseStream
                        Using fs As New IO.FileStream("Downloaded_file.jpg", FileMode.Create, FileAccess.Write)
                            Dim buffer(2047) As Byte
                            Dim read As Integer
                            Do
                                read = responseStream.Read(buffer, 0, buffer.Length)
                                fs.Write(buffer, 0, read)
                            Loop Until read = 0
                            responseStream.Close()
                            fs.Flush()
                            fs.Close()
                        End Using
                        responseStream.Close()
                    End Using
                    oResponse.Close()
                End Using
            Catch ex As Exception
                File.WriteAllText("error.txt", ex.ToString)
            End Try
    and it's not working,it simply creates a blank jpg file and the exception as per error.txt is

    System.Net.WebException: The remote name could not be resolved: 'proxy-service.https.de'
    at System.Net.HttpWebRequest.GetResponse()
    at dummy_proj.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\dummy_proj\dummy_proj\Form1.vb:line 13
    And now i am clue less,please help anybody anything?

  2. #2

    Thread Starter
    Junior Member praveenverma's Avatar
    Join Date
    Dec 2008
    Posts
    29

    Re: downloading a file from HTTPS using proxy

    well i think i find a solution i have to use an iport proxy instead of a web proxy

    Code:
    Dim proxy As New System.Net.WebProxy("109.73.52.227:3128", True)
    this is working fine now,thanks anyway

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width