1. Content-type for Binary File

How would I transfer a file via HTTP using mic's URLMON?

Right now I can do this:

   if get_file({"library.esp?getlist","library.esp"}) then
      if get_file({"getform.esp?rrc_p-1.dot","rrc_p-1.dot"}) then end if
   end if

get_file takes a URL (which is also the filename) -or- a URL and filename
(like above) and saves the download result into the filename. For the
library.esp?getlist URL above, it works fine. But for the .DOT file (which
is a Microsoft Word template), it cuts out at about 28kb, even though the
file is about 400kb. I'm sure it's because I'm using "Content-type:
text/plain;," but I don't know what to use.

Is there a better way to retrieve a binary file via HTTP WITHOUT having
to use a third-party software (like LibCurl, etc.)?

Of course, on the server side, the library.esp and getform.esp items are
Euphoria programs that are supposed to serve up something over the HTTP
connection. Works fine for text/html... :)

Thanks!!!
-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » topic index » view message » categorize

2. Re: Content-type for Binary File

On 21 Oct 2004, at 13:33, cklester wrote:

> 
> 
> posted by: cklester <cklester at yahoo.com>
> 
> How would I transfer a file via HTTP using mic's URLMON?
> 
> Right now I can do this:
> 
>    if get_file({"library.esp?getlist","library.esp"}) then
>       if get_file({"getform.esp?rrc_p-1.dot","rrc_p-1.dot"}) then end if
>    end if
> 
> get_file takes a URL (which is also the filename) -or- a URL and filename
> (like above) and saves the download result into the filename. For the
> library.esp?getlist URL above, it works fine. But for the .DOT file (which
> is a Microsoft Word template), it cuts out at about 28kb, even though the
> file is about 400kb. I'm sure it's because I'm using "Content-type:
> text/plain;," but I don't know what to use.

Use  *.* , but i don't think that's the problem. Not all servers care about what
content type you say you can accept, and if it did care then it wouldn't send 
you the first 28K of it.

> Is there a better way to retrieve a binary file via HTTP WITHOUT having
> to use a third-party software (like LibCurl, etc.)?

None that i know of.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: Content-type for Binary File

Kat wrote:
> On 21 Oct 2004, at 13:33, cklester wrote:
> > posted by: cklester <cklester at yahoo.com>
> > How would I transfer a file via HTTP using mic's URLMON?
> > Right now I can do this:
> >    if get_file({"library.esp?getlist","library.esp"}) then
> >       if get_file({"getform.esp?rrc_p-1.dot","rrc_p-1.dot"}) then end if
> >    end if
> > get_file takes a URL (which is also the filename) -or- a URL and filename
> > (like above) and saves the download result into the filename. For the
> > library.esp?getlist URL above, it works fine. But for the .DOT file (which
> > is a Microsoft Word template), it cuts out at about 28kb, even though the
> > file is about 400kb. I'm sure it's because I'm using "Content-type:
> > text/plain;," but I don't know what to use.
> Use  *.* , but i don't think that's the problem. Not all servers care about
> what
> content type you say you can accept, and if it did care then it wouldn't send 
> you the first 28K of it.

Kat, I tried using *.* as Content-type, but that still only gave me
27K or so.

Here's the code on the server that is sending the file... Maybe this needs
to be modified... (typed in, not copied)...

fn = open("c:\\templates\\" & form2send,"rb")
if fn > 0 then
   puts(1,"Content-type: *.*;\n\n")
   part = gets(fn)
   while not atom(part) do
      puts(1,part)
      part = gets(fn)
   end while
end if

Now, I know there's a get_bytes(), but that didn't seem to work either. But maybe I wasn't using it properly. So, if anybody can help me out, thanks in advance! :)

-=ck "Programming in a state of EUPHORIA." http://www.cklester.com/euphoria/ }}}

new topic     » goto parent     » topic index » view message » categorize

4. Re: Content-type for Binary File

On 21 Oct 2004, at 14:11, cklester wrote:

> 
> 
> posted by: cklester <cklester at yahoo.com>
> 
> Kat wrote:
> > On 21 Oct 2004, at 13:33, cklester wrote:
> > > posted by: cklester <cklester at yahoo.com>
> > > How would I transfer a file via HTTP using mic's URLMON?
> > > Right now I can do this:
> > >    if get_file({"library.esp?getlist","library.esp"}) then
> > >       if get_file({"getform.esp?rrc_p-1.dot","rrc_p-1.dot"}) then end if
> > >    end if
> > > get_file takes a URL (which is also the filename) -or- a URL and filename
> > > (like above) and saves the download result into the filename. For the
> > > library.esp?getlist URL above, it works fine. But for the .DOT file (which
> > > is a Microsoft Word template), it cuts out at about 28kb, even though the
> > > file is about 400kb. I'm sure it's because I'm using "Content-type:
> > > text/plain;," but I don't know what to use.
> > Use  *.* , but i don't think that's the problem. Not all servers care about
> > what content type you say you can accept, and if it did care then it
> > wouldn't
> > send you the first 28K of it.
> 
> Kat, I tried using *.* as Content-type, but that still only gave me
> 27K or so.
> 
> Here's the code on the server that is sending the file... Maybe this needs
> to be modified... (typed in, not copied)...
> 
> }}}
<eucode>
> fn = open("c:\\templates\\" & form2send,"rb")
> if fn > 0 then
>    puts(1,"Content-type: *.*;\n\n")

Why the semicolon there? If you have multiple types, they are to be 
separated by a comma, and there is no semicolon or comma at the end. But 
i don't know if that is the bug or not.

If possible, i would try to not read a byte at a time, maybe use one of 
Euman's winapi tricks to move chunks of the file into memory and feed it out 
from there. Since his way is outside Euphoria, the used memory is 
reclaimable by the OS. Of course, if you use nix, i don't know.

Kat

new topic     » goto parent     » topic index » view message » categorize

5. Re: Content-type for Binary File

>From: cklester <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Re: Content-type for Binary File
>Date: Thu, 21 Oct 2004 14:11:01 -0700
>
>posted by: cklester <cklester at yahoo.com>
>
>Kat wrote:
> > On 21 Oct 2004, at 13:33, cklester wrote:
> > > posted by: cklester <cklester at yahoo.com>
> > > How would I transfer a file via HTTP using mic's URLMON?
> > > Right now I can do this:
> > >    if get_file({"library.esp?getlist","library.esp"}) then
> > >       if get_file({"getform.esp?rrc_p-1.dot","rrc_p-1.dot"}) then end 
>if
> > >    end if
> > > get_file takes a URL (which is also the filename) -or- a URL and 
>filename
> > > (like above) and saves the download result into the filename. For the
> > > library.esp?getlist URL above, it works fine. But for the .DOT file 
>(which
> > > is a Microsoft Word template), it cuts out at about 28kb, even though 
>the
> > > file is about 400kb. I'm sure it's because I'm using "Content-type:
> > > text/plain;," but I don't know what to use.
> > Use  *.* , but i don't think that's the problem. Not all servers care 
>about what
> > content type you say you can accept, and if it did care then it wouldn't 
>send
> > you the first 28K of it.
>
>Kat, I tried using *.* as Content-type, but that still only gave me
>27K or so.
>

     Content-Type for Word documents should be "application/msword". But you 
have bigger problems...

>Here's the code on the server that is sending the file... Maybe this needs
>to be modified... (typed in, not copied)...
>
>}}}
<eucode>
>fn = open("c:\\templates\\" & form2send,"rb")
>if fn > 0 then
>    puts(1,"Content-type: *.*;\n\n")
>    part = gets(fn)
>    while not atom(part) do
>       puts(1,part)
>       part = gets(fn)
>    end while
>end if
>
>Now, I know there's a get_bytes(), but that didn't seem to work either.
>But maybe I wasn't using it properly. So, if anybody can help me out,
>thanks in advance! :)
>

     The Euphoria interpreter does not output to stdout in binary. There is 
no built-in method to change this output format. You therefore have no way 
of sending your binary data correctly in standard Euphoria. You might, 
however, be able to use the Windows API's to change the settings, or just 
output the file, as kat suggested.

>-=ck
>"Programming in a state of EUPHORIA."
>http://www.cklester.com/euphoria/
>

~[ WingZone ]~
http://wingzone.tripod.com/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu