Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using InternetWriteFile with HTTP

856 views
Skip to first unread message

MichaelR

unread,
Apr 11, 2004, 12:56:54 PM4/11/04
to
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

unread,
Apr 12, 2004, 4:01:04 PM4/12/04
to
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

----
David Whitman <da...@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

unread,
Apr 13, 2004, 3:58:11 PM4/13/04
to
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" <ad...@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#HEHA...@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

MichaelR

unread,
Apr 13, 2004, 4:44:57 PM4/13/04
to
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" <Br...@online.microsoft.com> wrote in message
news:IPu0sGZ...@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" <ad...@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#HEHA...@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

Paul Baker [MVP, Windows - SDK]

unread,
Apr 13, 2004, 4:55:23 PM4/13/04
to
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" <ad...@info-resonance.com> wrote in message
news:%23$RHwgZI...@TK2MSFTNGP12.phx.gbl...

Brian Combs

unread,
Apr 15, 2004, 11:56:04 AM4/15/04
to
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]" <pa...@online.rochester.rr.com>
| References: <#C4$WX#HEHA...@TK2MSFTNGP09.phx.gbl>
<IPu0sGZ...@cpmsftngxa06.phx.gbl>
<#$RHwgZI...@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: <eAPwkmZI...@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

0 new messages