Downloading

  • Thread starter Thread starter Lespaul36
  • Start date Start date
L

Lespaul36

I am trying to make a downloader using sockets to download pictures from a
website
I have to log in to the website, so I am adding a line for authentication
"Authentication Basic base64(user:pass). But I get back a page that says
user must login. The address is a secure server (https://domain.com). Do I
need to do something different?
 
If you are using the Socket class to connect to the server and manually
writing and parsing HTTP headers, you will need to use
System.Security.SslStream to handle SSL handshaking with the secure server.
First, create a NetworkStream encapsulating your Socket, and create a new
SslStream which encapsulates the NetworkStream. Then call
SslStream.AuthenticateAsClient to perform handshaking. Once complete, you
can use the SslStream as needed to read and write data securely to the
endpoint.

Another option would be to use System.Net.WebClient to grab data from a web
server. WebClient will automatically write and parse HTTP headers (of
course) and automatically utilize SSL if necessary.

Hope this helps,
Andrew
 
Back
Top