Download file

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Download file

Darius Blaszyk
Question:
I would like to download a file via HTTP, how can I achieve that in a
platform independent way? What components to use and is there some code
suited for dummy's available.

Darius

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Download file

Paul Davidson
The silly answer.  Construct an HTTP message according to IETF/W3C
rules.

Better answer.  Assuming you have a socket connection open, the
following should be included
in your message:

HTTP/1.0 200<crlf>
Connection: Close<crlf>
Content-length:<number of byte in Content: below, as ASCII string>
Content-type:<text/ascii, or something similar><crlf>
MIME-version:1.0<crlf>
<crlf>
<content>

The above should be in single string.
<crlf> means carriage return/line feed, or ASCII chars 10 and 13.
Content-type is important.  text/ASCII will work in most situations.
Otherwise see MIME standards at http://www.ietf.org for more details.
Please note that is extra <crlf> after text headers.  This is to
indicate that what follows is the data you want to transmit.

There are many other fields that can be added, depending on who is at
other end of connection, but the ones above should work in most
situation.  This is NOT ACID compliant.

See http://www.w3.org/Protocols/ for more details on HTTP.

On Nov 17, 2005, at 16:18, [hidden email] wrote:

> Question:
> I would like to download a file via HTTP, how can I achieve that in a
> platform independent way? What components to use and is there some code
> suited for dummy's available.
>
> Darius
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Download file

L505
In reply to this post by Darius Blaszyk
> Question:
> I would like to download a file via HTTP, how can I achieve that in a

Synapse is nice..

Note: It is not 100 percent platform independent.

(works on Linux and Windows possibly other operating systems.)


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Download file

Paul Davidson
It does not work as is on Mac, but then, most people don't care.  *cry*

On Nov 17, 2005, at 18:42, L505 wrote:

>> Question:
>> I would like to download a file via HTTP, how can I achieve that in a
>
> Synapse is nice..
>
> Note: It is not 100 percent platform independent.
>
> (works on Linux and Windows possibly other operating systems.)
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

IMPORTANT NOTICE:  This message is intended only for the use of the
individual or entity to which it is addressed. The message may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.  If the reader of this message is not the
intended recipient, or the employee or agent responsible for delivering
the message to the intended recipient, you are notified that any
dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify Corax Networks immediately by email at
[hidden email].  Thank you.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Download file

Jeff Pohlmeyer
In reply to this post by Darius Blaszyk
> I would like to download a file via HTTP, how can I achieve that in a
> platform independent way? What components to use and is there
> some code suited for dummy's available.


If you don't mind using an external DLL, CurlPas is quite simple,
and works on Linux, Windows, and possibly even Mac...

========================
program simple;
uses curl_obj;
var
  Curl:TCurl;
begin
  Curl:=TCurl.Create(nil);
  Curl.URL:='http://www.freepascal.org/index.html';
  Curl.OutputFile:='fpc.htm';
  if ( not Curl.Perform ) then WriteLn(Curl.ErrorString);
  Curl.Free;
end;
=====================

And that's all there is to it! The library can automatically
follow any redirects, deal with cookies, handle https and ftp
downloads, etc, etc, etc...

For more info, see:
  http://curlpas.sourceforge.net/
  http://curl.haxx.se/libcurl/


 - Jeff

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RE: Download file

Tony Pelton
On 11/18/05, Jeff Pohlmeyer <[hidden email]> wrote:
>
> If you don't mind using an external DLL, CurlPas is quite simple,

and presumably, if you are crafty, and licensing supports it, you
could link the curlpas runtime statically such that you don't need the
lib.

Tony
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
L-9
Reply | Threaded
Open this post in threaded view
|

Re: Download file

L-9
In reply to this post by Paul Davidson



> It does not work as is on Mac, but then, most people don't care.  *cry*
>

<rant flamebait offtopic>
I would consider a Mac if they didn't weld them shut like those iMacs. Talk about
closed source hardware.

Of course for every complaint I make someone will come back with "but you can buy
Macs with a tower case and a separate monitor". That's not the point. The point is
that the majority of them out there are welded shut (if I were to buy a used one for
example).

I'm quite interested in Mac's since they have a Pascal history.

But they sure ruined it with Jobs' colorful Pascal poster and colorful welded shut
iMacs. Otherwise, I would have researched them further. I've also had quite a few
crashes when setting up a Mac for networking, so the "no bugs on Macs" pick-up line
doesn't hold out. I would never ever claim that XYZ computer has less bugs than ABC
computer if I was a marketing company. That's poor marketing and just asking to be
proven wrong.
</rant flamebait offtopic>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Download file

Paul Davidson
Nice rant :)

On Nov 18, 2005, at 15:48, L wrote:

>
>
>
>> It does not work as is on Mac, but then, most people don't care.  
>> *cry*
>>
>
> <rant flamebait offtopic>
> I would consider a Mac if they didn't weld them shut like those iMacs.
> Talk about
> closed source hardware.
>
> Of course for every complaint I make someone will come back with "but
> you can buy
> Macs with a tower case and a separate monitor". That's not the point.
> The point is
> that the majority of them out there are welded shut (if I were to buy
> a used one for
> example).
>
> I'm quite interested in Mac's since they have a Pascal history.
>
> But they sure ruined it with Jobs' colorful Pascal poster and colorful
> welded shut
> iMacs. Otherwise, I would have researched them further. I've also had
> quite a few
> crashes when setting up a Mac for networking, so the "no bugs on Macs"
> pick-up line
> doesn't hold out. I would never ever claim that XYZ computer has less
> bugs than ABC
> computer if I was a marketing company. That's poor marketing and just
> asking to be
> proven wrong.
> </rant flamebait offtopic>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

IMPORTANT NOTICE:  This message is intended only for the use of the
individual or entity to which it is addressed. The message may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.  If the reader of this message is not the
intended recipient, or the employee or agent responsible for delivering
the message to the intended recipient, you are notified that any
dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify Corax Networks immediately by email at
[hidden email].  Thank you.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Download file

Jonas Maebe-2
In reply to this post by L-9

On 18 Nov 2005, at 21:48, L wrote:

>> It does not work as is on Mac, but then, most people don't care.  
>> *cry*
>
> <rant flamebait offtopic>
> I would consider a Mac if they didn't weld them shut like those  
> iMacs. Talk about
> closed source hardware.

Please post such drivel on fpc-other in the future, that's what that  
list is for.


Jonas
fpc mailing lists moderator
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal