Solved

InternetConnect http question

Posted on 2001-06-12
4
335 Views
Last Modified: 2013-12-03
I'm haveing a bit of trouble understanding the WinInet InternetConnect function call as it applies to username & password for a http session.

The documentation says:
; a NULL parameter in HTTP causes the server to return an error
Is that really true!!?? and just what is InternetConnect doing at this point for a http session? Just opening a socket? If so what would it do with any username and password supplied anyway? Maybe save them up and use them in subsequent HttpOpenRequest?

Any insight into what is going on with respect to user details and the InternetConnect function as far as http is concerned would be greatly appreciated.
0
Comment
Question by:GGRUNDY
  • 2
4 Comments
 
LVL 5

Expert Comment

by:robpitt
ID: 6180417
Darn good question! I see no reason why NULL could not have been accepted yet the docs do indeed state a username paramter is required for HTTP.


As for asking for the username/password at this early stage, well I guess its just so that it can cache it for use later on when a page requiring authentication is encountered.
0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 6180864
If no username or password is needed you pass it an EMPTY STRING but NOT NULL!  There is a difference:

TCHAR *lpszEMPTYSTRING = _T("");

is distinct from:

TCHAR *lpszNULLSTRING = NULL;

As to WHY?  Who knows?  Probably some lazy programmer forgot to take care of this and rather than change the code, they changed the docs.  

Look at the bright side.  At LEAST THEY DOCUMENTED IT!!  
0
 
LVL 3

Author Comment

by:GGRUNDY
ID: 6184051
Hi Guys thanks for your comments thus far.
But I'm still pretty interested in what (if anything) it does with username & password in the case of internet connection.
I have since found a document which says that in the case of a HTTP connection InternetConnect doesn't go anywhere near the site at that point. http://msdn.microsoft.com/workshop/networking/wininet/overview/enable.asp
From the article
InternetConnect does not attempt to access or establish a connection to the specified site, except in the case of an ftp session.

I also note that MFC's CHttpConnection class seems quite keen to pass NULL parameters for Username and Password. So it is probably the documentation in error. (Although the above article repeats the fallacy).
(In fact I get the impression from the documentation of the InternetConnect function had an author with only a passing acquaintanceship with the English language).
0
 
LVL 3

Author Comment

by:GGRUNDY
ID: 6199397
Thanks for trying anyway guys
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now