-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed7115b
commit 39d4b13
Showing
18 changed files
with
636 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30907.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectionSample", "ReflectionSample\ReflectionSample.csproj", "{DE65DD7D-9DAE-4102-B29C-03276742EB2B}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecTest", "ExecTest\ExecTest.csproj", "{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExternalExeCall", "ExternalExeCall\ExternalExeCall.csproj", "{074D07BF-12F5-4995-B74F-9955F0B14D5E}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicWebServerUrlParser", "BasicWebServer\BasicWebServerUrlParser.csproj", "{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DE65DD7D-9DAE-4102-B29C-03276742EB2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DE65DD7D-9DAE-4102-B29C-03276742EB2B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DE65DD7D-9DAE-4102-B29C-03276742EB2B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DE65DD7D-9DAE-4102-B29C-03276742EB2B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{074D07BF-12F5-4995-B74F-9955F0B14D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{074D07BF-12F5-4995-B74F-9955F0B14D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{074D07BF-12F5-4995-B74F-9955F0B14D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{074D07BF-12F5-4995-B74F-9955F0B14D5E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {EB2F176A-128D-4176-B75A-A077013CA20D} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{B6A28AAE-DA86-41D3-8A15-9B529A3AD71C}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>BasicWebServer</RootNamespace> | ||
<AssemblyName>BasicWebServer</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Web" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> | ||
<StartArguments>http://localhost:8080/ http://localhost:8081/</StartArguments> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Net; | ||
using System.Text; | ||
using System.Web; | ||
|
||
namespace BasicServerHTTPlistener | ||
{ | ||
internal class Program | ||
{ | ||
private static void Main(string[] args) | ||
{ | ||
|
||
//if HttpListener is not supported by the Framework | ||
if (!HttpListener.IsSupported) | ||
{ | ||
Console.WriteLine("A more recent Windows version is required to use the HttpListener class."); | ||
return; | ||
} | ||
|
||
|
||
// Create a listener. | ||
HttpListener listener = new HttpListener(); | ||
|
||
// Add the prefixes. | ||
if (args.Length != 0) | ||
{ | ||
foreach (string s in args) | ||
{ | ||
listener.Prefixes.Add(s); | ||
// don't forget to authorize access to the TCP/IP addresses localhost:xxxx and localhost:yyyy | ||
// with netsh http add urlacl url=http://localhost:xxxx/ user="Tout le monde" | ||
// and netsh http add urlacl url=http://localhost:yyyy/ user="Tout le monde" | ||
// user="Tout le monde" is language dependent, use user=Everyone in english | ||
|
||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Syntax error: the call must contain at least one web server url as argument"); | ||
} | ||
listener.Start(); | ||
|
||
// get args | ||
foreach (string s in args) | ||
{ | ||
Console.WriteLine("Listening for connections on " + s); | ||
} | ||
|
||
// Trap Ctrl-C on console to exit | ||
Console.CancelKeyPress += delegate { | ||
// call methods to close socket and exit | ||
listener.Stop(); | ||
listener.Close(); | ||
Environment.Exit(0); | ||
}; | ||
|
||
|
||
while (true) | ||
{ | ||
// Note: The GetContext method blocks while waiting for a request. | ||
HttpListenerContext context = listener.GetContext(); | ||
HttpListenerRequest request = context.Request; | ||
|
||
string documentContents; | ||
using (Stream receiveStream = request.InputStream) | ||
{ | ||
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) | ||
{ | ||
documentContents = readStream.ReadToEnd(); | ||
} | ||
} | ||
|
||
// get url | ||
Console.WriteLine($"Received request for {request.Url}"); | ||
|
||
//get url protocol | ||
Console.WriteLine(request.Url.Scheme); | ||
//get user in url | ||
Console.WriteLine(request.Url.UserInfo); | ||
//get host in url | ||
Console.WriteLine(request.Url.Host); | ||
//get port in url | ||
Console.WriteLine(request.Url.Port); | ||
//get path in url | ||
Console.WriteLine(request.Url.LocalPath); | ||
|
||
// parse path in url | ||
foreach (string str in request.Url.Segments) | ||
{ | ||
Console.WriteLine(str); | ||
} | ||
|
||
//get params un url. After ? and between & | ||
|
||
Console.WriteLine(request.Url.Query); | ||
|
||
//parse params in url | ||
Console.WriteLine("param1 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param1")); | ||
Console.WriteLine("param2 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param2")); | ||
Console.WriteLine("param3 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param3")); | ||
Console.WriteLine("param4 = " + HttpUtility.ParseQueryString(request.Url.Query).Get("param4")); | ||
|
||
// | ||
Console.WriteLine(documentContents); | ||
|
||
// Obtain a response object. | ||
HttpListenerResponse response = context.Response; | ||
|
||
// Construct a response. | ||
string responseString = "<HTML><BODY> Hello world!</BODY></HTML>"; | ||
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); | ||
// Get a response stream and write the response to it. | ||
response.ContentLength64 = buffer.Length; | ||
System.IO.Stream output = response.OutputStream; | ||
output.Write(buffer, 0, buffer.Length); | ||
// You must close the output stream. | ||
output.Close(); | ||
} | ||
// Httplistener neither stop ... But Ctrl-C do that ... | ||
// listener.Stop(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("BasicWebServer")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("BasicWebServer")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("b6a28aae-da86-41d3-8a15-9b529a3ad71c")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{48CE08C3-C3F7-45C2-B764-5D0CE14B79F6}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>ExecTest</RootNamespace> | ||
<AssemblyName>ExecTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace ExeTest | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
if (args.Length == 1) | ||
Console.WriteLine(args[0]); | ||
else | ||
Console.WriteLine("ExeTest <string parameter>"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("ExecTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("ExecTest")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("48ce08c3-c3f7-45c2-b764-5d0ce14b79f6")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Oops, something went wrong.