ReceiveHTTPFile() with userID and password, possible?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

ReceiveHTTPFile() with userID and password, possible?

Post by Jacobus »

Hello, is it possible to download a file with ID and password on http://... ??
The following code doesn't work. (example)

Code: Select all

InitNetwork()
Filezip$ = SaveFileRequester("Where to save filename.zip ?", "", "", 0)
 If Filezip$
  user.s = "userid"
  pass.s = "passw"
  If ReceiveHTTPFile("http://"+user+":"+pass+"@www.domain.com/filename.zip", Filezip$)
    Debug "Download done"
  Else
    Debug "Download failed"
  EndIf 
 EndIf
PureBasicien tu es, PureBasicien tu resteras.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: ReceiveHTTPFile() with userID and password, possible?

Post by Rook Zimbabwe »

Does this work:

Code: Select all

user$ = "user"
pass$ = "pass"
ReceiveHTTPFile("http://"+user$+":"+pass$+"@www.domain.com/filename.zip", "C:\filename.zip")
all by its lonesome in the program?

If not... it might be your user/password because I think that is for FTP but I am unsure...
have you tried:

Code: Select all

ReceiveFTPFile(#PB_Any, "http://"+user$+":"+pass$+"@www.domain.com/filename.zip", "C:\filename.zip") , Asynchronous)
:mrgreen:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

Re: ReceiveHTTPFile() with userID and password, possible?

Post by Jacobus »

Thanks. I shall try as soon as possible.
PureBasicien tu es, PureBasicien tu resteras.
a.ross
User
User
Posts: 21
Joined: Tue Dec 08, 2009 12:50 am

Re: ReceiveHTTPFile() with userID and password, possible?

Post by a.ross »

I would say no, not the way you doing it according to this snippet I found on the interweb:
Of the predefined schemes listed (http, ftp, news, nntp, telnet, gopher
wais, mailto, file, prospero), only ftp: and telnet: URLs use the login
form, which allows for a password. http: uses only hostport.

So the syntax in the spec doesn't allow for what you want. See:
http://www.w3.org/hypertext/WWW/Address ... ssing.html
http://www.w3.org/hypertext/WWW/Addressing/rfc1738.txt

In the HTTP 1.0 protocol (with Basic Authentication) the user name and
password are not sent as part of the URL on the GET line, but rather in a
"Authorization:" header sent in response to a "WWW-Authenticate:" header
sent when a prior request failed.

The HTTP spec also agrees that the http: URL has the form:

http_URL = "http:" "//" host [ ":" port ] [ abs_path ]

See:
http://www.w3.org/hypertext/WWW/Protocols/Overview.html
http://www.w3.org/hypertext/WWW/Protoco ... /spec.html

While you could write a custom client that would do a GET with a username
and password by sending the right headers with the request, trying to use
the generic URL syntax to do this is not going to work.

(There are other authorization schemes in the works besides Basic, but it
is still widely used.)

(Also note: While the spec for telnet URLs allows for a username and
password, you are unlikely to find this implemented.)
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Re: ReceiveHTTPFile() with userID and password, possible?

Post by TerryHough »

Not with the built in PB command ReceiveHTTPFile() I don't believe.

But, look at this link for a way to do it.
http://www.purebasic.fr/english/viewtop ... e+download
User avatar
Jacobus
Enthusiast
Enthusiast
Posts: 139
Joined: Wed Nov 16, 2005 7:51 pm
Location: France
Contact:

Re: ReceiveHTTPFile() with userID and password, possible?

Post by Jacobus »

Thanks at all.
@TerryHough, The Luis code is just perfect for my needs. The multiple ways in which it placed at our disposal are very sufficient. Luis if you pass through here, be thanked for your sharing. :)
PureBasicien tu es, PureBasicien tu resteras.
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Re: ReceiveHTTPFile() with userID and password, possible?

Post by TerryHough »

I failed to show you the link to a related topic that may be useful too.

http://www.purebasic.fr/english/viewtop ... p+download

I agree. Luis did us all a big favor with his code. I've much appreciated it.
Post Reply