Result = ReceiveHTTPFile(URL$, Filename$)
example
http://nr3.coolverse.jp/_userdata/downl ... =nr3_beta2
Download Access counter, Redirect then send file. I want to use linux version.
Could you support redirect mode?
ReceiveHTTPFile - Redirect support
Re: ReceiveHTTPFile - Redirect support
Hi oryaaaaa,oryaaaaa wrote:Result = ReceiveHTTPFile(URL$, Filename$)
example
http://nr3.coolverse.jp/_userdata/downl ... =nr3_beta2
Download Access counter, Redirect then send file. I want to use linux version.
Could you support redirect mode?
You can implement this your self using the tools that are at your disposal. Since this method uses nothing but the built in functions it should be cross platform.
Code: Select all
InitNetwork()
CreateRegularExpression(0, "(302|301)")
CreateRegularExpression(1, "http://.*$")
CreateRegularExpression(2, "http://.*/")
CreateRegularExpression(3, "200")
inputurl$ = ProgramParameter(0)
Procedure.s Parse302(url$)
Header$ = GetHTTPHeader(url$)
Index = 0
Index+1
Line$ = StringField(Header$, Index, #LF$)
If MatchRegularExpression(0, Line$)
Debug "302 FOUND!... Parsing."
Repeat
Index+1
Line$ = StringField(Header$, Index, #LF$)
Until MatchRegularExpression(1, Line$)
Dim Result$(0)
ExtractRegularExpression(1, Line$, Result$())
Debug Result$(0)
Else
Debug url$
ProcedureReturn url$
EndIf
ProcedureReturn Result$(0)
EndProcedure
Repeat
inputurl$ = Parse302(inputurl$)
Header$ = GetHTTPHeader(inputurl$)
Index = 0
Index+1
Line$ = StringField(Header$, Index, #LF$)
Until MatchRegularExpression(3, Line$)
Debug "Attempting to download file."
Dim Result$(0)
filename$ = GetCurrentDirectory() + ReplaceRegularExpression(2, inputurl$, "")
filename$ = Left(filename$, Len(filename$)-1)
Debug filename$
PrintN("Downloading file: " + filename$)
ReceiveHTTPFile(inputurl$, filename$)
PrintN("Done!")
This code when compiled takes one param via the commanline, the url. Best to encapsulate the url with quotes as some of the characters in URLs don't make bash very happy.
Anyway sorry for the rough code I have been away from PB for a while and I'm starting to pick it back up.
Hope it helps.
Boop64