Discussion:
Using InternetWriteFile with HTTP
(too old to reply)
MichaelR
2004-04-11 16:56:54 UTC
Permalink
My program needs to send files from a client machine to a server and I would
like to use HTTP to do so. I know FTP was designed for such a purpose, but
there are security concerns and I intend to use SSL for the file transfer.

I have two questions:

1. With FTP I can specify a file name to open and use InternetWriteFile to
create the file in a specified directory. Is it possible to use
InternetWriteFile with HTTP to write files directly into a specified
directory (assuming the user has write access to that directory)? Or do I
need to have an ASP script (or something similar) on the server to receive
the request and create the file?

2. I know that with HTTP, I need to use HttpSendRequestEx if I want to use
InternetWriteFile. However, I can't find any good documentation or examples
on how to use the function, especially the INTERNET_BUFFERS structure in the
context of an HSR_CHUNKED request. Can anyone point me to some
documentation or sample code?

Thanks.
David Whitman
2004-04-12 20:01:04 UTC
Permalink
Hi Michael,

If you'd like to make life real simple for yourself, why don't you
download and try out a copy of our Catalyst File Transfer Control. It
includes FTP, FTPS, HTTP and HTTPS capabilities all in one simple to
use component. There are samples included that will do what you want.

You can download a fully functional evaluation copy at:

http://www.catalyst.com/products/filetransfer/index.html

David



On Sun, 11 Apr 2004 12:56:54 -0400, "MichaelR"
Post by MichaelR
My program needs to send files from a client machine to a server and I would
like to use HTTP to do so. I know FTP was designed for such a purpose, but
there are security concerns and I intend to use SSL for the file transfer.
1. With FTP I can specify a file name to open and use InternetWriteFile to
create the file in a specified directory. Is it possible to use
InternetWriteFile with HTTP to write files directly into a specified
directory (assuming the user has write access to that directory)? Or do I
need to have an ASP script (or something similar) on the server to receive
the request and create the file?
2. I know that with HTTP, I need to use HttpSendRequestEx if I want to use
InternetWriteFile. However, I can't find any good documentation or examples
on how to use the function, especially the INTERNET_BUFFERS structure in the
context of an HSR_CHUNKED request. Can anyone point me to some
documentation or sample code?
Thanks.
----
David Whitman <***@catalyst.com> | Catalyst Internet Mail and File
Catalyst Development Corporation | Transfer, 2 New integrated controls
http://www.catalyst.com/ | requiring VERY little coding to use.
Brian Combs
2004-04-13 19:58:11 UTC
Permalink
Hello
See the following article.
184352 HOWTO: Upload Files to the Internet Information Server
http://support.microsoft.com/?id=184352

Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "MichaelR" <***@info-resonance.com>
| Subject: Using InternetWriteFile with HTTP
| Date: Sun, 11 Apr 2004 12:56:54 -0400
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Message-ID: <#C4$WX#***@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: mail.info-resonance.com 199.171.27.66
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.inetsdk.programming.wininet:10910
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| My program needs to send files from a client machine to a server and I
would
| like to use HTTP to do so. I know FTP was designed for such a purpose,
but
| there are security concerns and I intend to use SSL for the file transfer.
|
| I have two questions:
|
| 1. With FTP I can specify a file name to open and use InternetWriteFile
to
| create the file in a specified directory. Is it possible to use
| InternetWriteFile with HTTP to write files directly into a specified
| directory (assuming the user has write access to that directory)? Or do I
| need to have an ASP script (or something similar) on the server to receive
| the request and create the file?
|
| 2. I know that with HTTP, I need to use HttpSendRequestEx if I want to
use
| InternetWriteFile. However, I can't find any good documentation or
examples
| on how to use the function, especially the INTERNET_BUFFERS structure in
the
| context of an HSR_CHUNKED request. Can anyone point me to some
| documentation or sample code?
|
| Thanks.
|
|
|
MichaelR
2004-04-13 20:44:57 UTC
Permalink
Thanks Brian. I actually found that article after my original post and
tried the method it suggested. But it seems that the article targets IIS
4.0 and I'm guessing that MS tightened up the security so that when I tried
it, I get 401 (if there is authentication required on the directory) and 501
codes (if there is no authentication).

I also found some MS articles that reference some intrinsic capabilities
(ASP utilities) for file uploads, but apparently they have been taken out of
the product and are no longer supported.

Another interesting quirk - apparently you can't do a HttpQueryInfo
immediately after a HttpSendRequestEx - I get a return code that the handle
is not in a state to respond. I've seen examples of HttpSendRequest
followed by HttpQueryInfo, but it doesn't work with HttpSendRequestEx. The
downside to this is that you can't get a status code until the entire file
has been written and the request has been ended. And some of these file
transfers can be quite large.

Mike
Post by Brian Combs
Hello
See the following article.
184352 HOWTO: Upload Files to the Internet Information Server
http://support.microsoft.com/?id=184352
Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Subject: Using InternetWriteFile with HTTP
| Date: Sun, 11 Apr 2004 12:56:54 -0400
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: mail.info-resonance.com 199.171.27.66
cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
Post by Brian Combs
phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.inetsdk.programming.wininet:10910
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| My program needs to send files from a client machine to a server and I
would
| like to use HTTP to do so. I know FTP was designed for such a purpose,
but
| there are security concerns and I intend to use SSL for the file transfer.
|
|
| 1. With FTP I can specify a file name to open and use InternetWriteFile
to
| create the file in a specified directory. Is it possible to use
| InternetWriteFile with HTTP to write files directly into a specified
| directory (assuming the user has write access to that directory)? Or do I
| need to have an ASP script (or something similar) on the server to receive
| the request and create the file?
|
| 2. I know that with HTTP, I need to use HttpSendRequestEx if I want to
use
| InternetWriteFile. However, I can't find any good documentation or
examples
| on how to use the function, especially the INTERNET_BUFFERS structure in
the
| context of an HSR_CHUNKED request. Can anyone point me to some
| documentation or sample code?
|
| Thanks.
|
|
|
Paul Baker [MVP, Windows - SDK]
2004-04-13 20:55:23 UTC
Permalink
The HTTP errors you describe can probably be corrected by a proper
configuration of the web server. It's probably not anything your client is
doing. You should test any page you want to write a client for in Internet
Explorer first.

I'm not sure which intrinsic ASP capabilities you are referring to, but the
article describes how to make an HTTP PUT request, and should apply equally
to any web server.

What are your parameters for HttpQueryInfo? Perhaps I can explain why the
information is not available immediately.

IIS, and certain other web servers, load the HTTP PUT request into memory
before parsing the headers and passing control to the web page, eg. the ASP
page. It is not suitable for uploading large files. In fact there is a limit
of 2GB in IIS 5 and 1GB in IIS 6 to avoid performance problems. You can
overload the whole server if you upload a file more than a couple of hundred
MB. I recommend FTP for large transfers.

Paul
Post by MichaelR
Thanks Brian. I actually found that article after my original post and
tried the method it suggested. But it seems that the article targets IIS
4.0 and I'm guessing that MS tightened up the security so that when I tried
it, I get 401 (if there is authentication required on the directory) and 501
codes (if there is no authentication).
I also found some MS articles that reference some intrinsic capabilities
(ASP utilities) for file uploads, but apparently they have been taken out of
the product and are no longer supported.
Another interesting quirk - apparently you can't do a HttpQueryInfo
immediately after a HttpSendRequestEx - I get a return code that the handle
is not in a state to respond. I've seen examples of HttpSendRequest
followed by HttpQueryInfo, but it doesn't work with HttpSendRequestEx.
The
Post by MichaelR
downside to this is that you can't get a status code until the entire file
has been written and the request has been ended. And some of these file
transfers can be quite large.
Mike
Post by Brian Combs
Hello
See the following article.
184352 HOWTO: Upload Files to the Internet Information Server
http://support.microsoft.com/?id=184352
Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no
rights.
Post by Brian Combs
--------------------
| Subject: Using InternetWriteFile with HTTP
| Date: Sun, 11 Apr 2004 12:56:54 -0400
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: mail.info-resonance.com 199.171.27.66
cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
Post by MichaelR
Post by Brian Combs
phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.inetsdk.programming.wininet:10910
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| My program needs to send files from a client machine to a server and I
would
| like to use HTTP to do so. I know FTP was designed for such a purpose,
but
| there are security concerns and I intend to use SSL for the file
transfer.
Post by Brian Combs
|
|
| 1. With FTP I can specify a file name to open and use
InternetWriteFile
Post by MichaelR
Post by Brian Combs
to
| create the file in a specified directory. Is it possible to use
| InternetWriteFile with HTTP to write files directly into a specified
| directory (assuming the user has write access to that directory)? Or
do
Post by MichaelR
I
Post by Brian Combs
| need to have an ASP script (or something similar) on the server to
receive
Post by Brian Combs
| the request and create the file?
|
| 2. I know that with HTTP, I need to use HttpSendRequestEx if I want to
use
| InternetWriteFile. However, I can't find any good documentation or
examples
| on how to use the function, especially the INTERNET_BUFFERS structure in
the
| context of an HSR_CHUNKED request. Can anyone point me to some
| documentation or sample code?
|
| Thanks.
|
|
|
Brian Combs
2004-04-15 15:56:04 UTC
Permalink
Hello
Also to address the following question: "HttpQueryInfo immediately after a
HttpSendRequestEx - I get a return code that the handle is not in a state
to respond. "

This is correct you must call HttpEndRequest to end the HTTP request that
was initiated by HttpSendReqeustEX. You cannot call HttpQueryInfo until
after you end the reqeust.

The Idea of HttpSendRequestEX is that I can send a large file using multi
calls to InternetWriteFile after calling HttpSendRequestEX. WinInet does
not consider the request to be finished until you call HttpEndRequest.


Thanks
Brian [MSFT]
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Paul Baker [MVP, Windows - SDK]" <***@online.rochester.rr.com>
| References: <#C4$WX#***@TK2MSFTNGP09.phx.gbl>
<***@cpmsftngxa06.phx.gbl>
<#$***@TK2MSFTNGP12.phx.gbl>
| Subject: Re: Using InternetWriteFile with HTTP
| Date: Tue, 13 Apr 2004 16:55:23 -0400
| Lines: 124
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <***@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.inetsdk.programming.wininet
| NNTP-Posting-Host: 66-192-38-10.bccsoftware.com 66.192.38.10
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.inetsdk.programming.wininet:10919
| X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
|
| The HTTP errors you describe can probably be corrected by a proper
| configuration of the web server. It's probably not anything your client is
| doing. You should test any page you want to write a client for in Internet
| Explorer first.
|
| I'm not sure which intrinsic ASP capabilities you are referring to, but
the
| article describes how to make an HTTP PUT request, and should apply
equally
| to any web server.
|
| What are your parameters for HttpQueryInfo? Perhaps I can explain why the
| information is not available immediately.
|
| IIS, and certain other web servers, load the HTTP PUT request into memory
| before parsing the headers and passing control to the web page, eg. the
ASP
| page. It is not suitable for uploading large files. In fact there is a
limit
| of 2GB in IIS 5 and 1GB in IIS 6 to avoid performance problems. You can
| overload the whole server if you upload a file more than a couple of
hundred
| MB. I recommend FTP for large transfers.
|
| Paul
|
| "MichaelR" <***@info-resonance.com> wrote in message
| news:%23$***@TK2MSFTNGP12.phx.gbl...
| > Thanks Brian. I actually found that article after my original post and
| > tried the method it suggested. But it seems that the article targets
IIS
| > 4.0 and I'm guessing that MS tightened up the security so that when I
| tried
| > it, I get 401 (if there is authentication required on the directory) and
| 501
| > codes (if there is no authentication).
| >
| > I also found some MS articles that reference some intrinsic capabilities
| > (ASP utilities) for file uploads, but apparently they have been taken
out
| of
| > the product and are no longer supported.
| >
| > Another interesting quirk - apparently you can't do a HttpQueryInfo
| > immediately after a HttpSendRequestEx - I get a return code that the
| handle
| > is not in a state to respond. I've seen examples of HttpSendRequest
| > followed by HttpQueryInfo, but it doesn't work with HttpSendRequestEx.
| The
| > downside to this is that you can't get a status code until the entire
file
| > has been written and the request has been ended. And some of these file
| > transfers can be quite large.
| >
| > Mike
| >
| >
| > "Brian Combs" <***@online.microsoft.com> wrote in message
| > news:***@cpmsftngxa06.phx.gbl...
| > > Hello
| > > See the following article.
| > > 184352 HOWTO: Upload Files to the Internet Information Server
| > > http://support.microsoft.com/?id=184352
| > >
| > > Thanks
| > > Brian [MSFT]
| > > Microsoft Developer Support
| > > This posting is provided "AS IS" with no warranties, and confers no
| > rights.
| > > --------------------
| > > | From: "MichaelR" <***@info-resonance.com>
| > > | Subject: Using InternetWriteFile with HTTP
| > > | Date: Sun, 11 Apr 2004 12:56:54 -0400
| > > | Lines: 22
| > > | X-Priority: 3
| > > | X-MSMail-Priority: Normal
| > > | X-Newsreader: Microsoft Outlook Express 6.00.3790.0
| > > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > > | Message-ID: <#C4$WX#***@TK2MSFTNGP09.phx.gbl>
| > > | Newsgroups: microsoft.public.inetsdk.programming.wininet
| > > | NNTP-Posting-Host: mail.info-resonance.com 199.171.27.66
| > > | Path:
| > >
| >
|
cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
| > > phx.gbl
| > > | Xref: cpmsftngxa06.phx.gbl
| > > microsoft.public.inetsdk.programming.wininet:10910
| > > | X-Tomcat-NG: microsoft.public.inetsdk.programming.wininet
| > > |
| > > | My program needs to send files from a client machine to a server
and I
| > > would
| > > | like to use HTTP to do so. I know FTP was designed for such a
| purpose,
| > > but
| > > | there are security concerns and I intend to use SSL for the file
| > transfer.
| > > |
| > > | I have two questions:
| > > |
| > > | 1. With FTP I can specify a file name to open and use
| InternetWriteFile
| > > to
| > > | create the file in a specified directory. Is it possible to use
| > > | InternetWriteFile with HTTP to write files directly into a specified
| > > | directory (assuming the user has write access to that directory)?
Or
| do
| > I
| > > | need to have an ASP script (or something similar) on the server to
| > receive
| > > | the request and create the file?
| > > |
| > > | 2. I know that with HTTP, I need to use HttpSendRequestEx if I want
| to
| > > use
| > > | InternetWriteFile. However, I can't find any good documentation or
| > > examples
| > > | on how to use the function, especially the INTERNET_BUFFERS
structure
| in
| > > the
| > > | context of an HSR_CHUNKED request. Can anyone point me to some
| > > | documentation or sample code?
| > > |
| > > | Thanks.
| > > |
| > > |
| > > |
| > >
| >
| >
|
|
|

Loading...