Advertisement
C_Volume2 Internet/ Browsers/ HTML #81318

CHTTPTransaction - C++/Win32 - Reusable Class

CHTTPTranscation is an enhancement for CHTTPSocket class, with full source code. Full qualified, multiple redirections support, HTTP client. Supports all previous features: virtual hosts, proxy servers, plus new redirections support for standart HTTP 3xx responses. In sample, CSampleTrans is a sample class derived from CHTTPTransaction, briefly shows You how to derive Your own class. In CHTTPSocket some changes applied, many member functions and variables now private and protected. I compile sample dts.exe to show how it's working, no changes in calling syntax from previous version

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Upload
In de .NET Framework are no build-in statements<br>
to access INI files. To do this, you must access the<br>
file directly or use the Win32 API's.<br>
<br>
In DotNet we now have Configuration Files.<br>
This are XML files that can be changed as needed<br>
without recompiling the application.<br>
<br>
There are four different kind of configuration files:<br>
- Machine Configuration Files<br>
- Application Configuration Files<br>
- Security Configuration Files<br>
- ASP.NET Configuration Files<br>
<br>
The Application Configuration File is to compare<br>
with an INI file. With one big difference that<br>
you only can Read settings, but not Write settings!<br>
Writing has to be done manualy.<br>
<br>
<br>
To use a configuration file you must add an<br>
'Application Configuration File' to your project.<br>
<br>
In the Visual Studio Environment this can be done by<br>
right clicking the project, choose 'add new item'.<br>
Then look for the item 'Application Configuration File'.<br>
This will add an 'App.Config' file to your project.<br>
<br>
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br>
&lt;configuration&gt;<br>
&lt;/configuration&gt;<br>
<br>
To add your own settings, you must add a section<br>
called 'appSettings'.<br>
<br>
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br>
&lt;configuration&gt;<br>
&lt;appSettings&gt;<br>
&lt;/appSettings&gt;<br>
&lt;/configuration&gt;<br>
<br>
Here you can store your settings as key/value pairs.<br>
<br>
&lt;?xml version="1.0" encoding="utf-8" ?&gt;<br>
&lt;configuration&gt;<br>
&lt;appSettings&gt;<br>
&lt;add key="Test1" value="This is the value of Test1" /&gt;<br>
&lt;add key="Test2" value="This is the value of Test2" /&gt;<br>
&lt;/appSettings&gt;<br>
&lt;/configuration&gt;<br>
<br>
!!! BEWARE.......THE TEXT IS CASE SENSITIVE !!!<br>
<br>
'appSettings' is not the same as 'appsettings'<br>
Notice the captial S.<br>
A runtime error will occure if you make a typing error.<br>
<br>
<br>
An VB.NET example to read from the Configuration file.<br>
<br>
Imports System<br>
Imports System.Console<br>
<br>
Module Module1<br>
<br>
Sub Main()<br>
Try<br>
Dim config As Configuration.ConfigurationSettings<br>
<br>
' Read the key:Test2<br>
WriteLine(config.AppSettings("Test2"))<br>
<br>
' To read all key's<br>
Dim key As String<br>
<br>
For Each key In config.AppSettings.AllKeys<br>
WriteLine(key &amp; " -- " &amp; config.AppSettings(key))<br>
Next<br>
<br>
WriteLine("")<br>
<br>
Catch ex As Exception<br>
WriteLine("")<br>
WriteLine(ex.ToString)<br>
<br>
Finally<br>
Read()<br>
<br>
End Try<br>
End Sub<br>
<br>
End Module<br>
<br>
<br>
After compiling the assembly, you also will get<br>
an config file in your bin directory.<br>
<br>
For example: an project called MyTest, results in<br>
MyTest.exe<br>
MyTest.exe.config<br>
<br>
The two files must be placed in the<br>
same directory to work.<br>
Original Comments (3)
Recovered from Wayback Machine