Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions OpenRasta.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRasta.DI.Windsor.Tests.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRasta.Hosting.AspNet.Tests.Integration", "src\OpenRasta.Hosting.AspNet.Tests.Integration\OpenRasta.Hosting.AspNet.Tests.Integration.csproj", "{088478E0-A0CB-40E1-88C6-A89B50330C6B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRasta.Plugins.Hydra", "src\OpenRasta.Plugins.Hydra\OpenRasta.Plugins.Hydra.csproj", "{05AD6BA1-C771-41DC-94B5-5D4CA2C8DB2F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRasta.Plugins.Hydra", "src\OpenRasta.Plugins.Hydra\OpenRasta.Plugins.Hydra.csproj", "{05AD6BA1-C771-41DC-94B5-5D4CA2C8DB2F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{F29C9EB9-4B9A-4D8D-A776-6A849CA73DA6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRastaDemo", "src\OpenRasta.Benchmarks\OpenRastaDemo\OpenRastaDemo.csproj", "{B262A705-C1B2-4C1A-AE34-3B15119F609E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRastaDemo", "src\OpenRasta.Benchmarks\OpenRastaDemo\OpenRastaDemo.csproj", "{B262A705-C1B2-4C1A-AE34-3B15119F609E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRastaDemo.Benchmark", "src\OpenRasta.Benchmarks\OpenRastaDemo.Benchmark\OpenRastaDemo.Benchmark.csproj", "{D5566579-4803-4CF6-AC60-25D7EC075F6C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRastaDemo.Benchmark", "src\OpenRasta.Benchmarks\OpenRastaDemo.Benchmark\OpenRastaDemo.Benchmark.csproj", "{D5566579-4803-4CF6-AC60-25D7EC075F6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRastaDemo.Shared", "src\OpenRasta.Benchmarks\OpenRastaDemo.Shared\OpenRastaDemo.Shared.csproj", "{D0389498-4624-4D02-93C5-69F02E678273}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenRastaDemo.Shared", "src\OpenRasta.Benchmarks\OpenRastaDemo.Shared\OpenRastaDemo.Shared.csproj", "{D0389498-4624-4D02-93C5-69F02E678273}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingKeepAlive.Web", "src\TestingKeepAlive.Web\TestingKeepAlive.Web.csproj", "{24B7B587-F7E7-4F56-BEA3-88F1A87C648C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingKeepAlive.Console", "src\TestingKeepAlive.Console\TestingKeepAlive.Console.csproj", "{81426C52-CD04-4C22-85E7-F4FF4FB4E865}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -121,16 +125,24 @@ Global
{D0389498-4624-4D02-93C5-69F02E678273}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0389498-4624-4D02-93C5-69F02E678273}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0389498-4624-4D02-93C5-69F02E678273}.Release|Any CPU.Build.0 = Release|Any CPU
{24B7B587-F7E7-4F56-BEA3-88F1A87C648C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24B7B587-F7E7-4F56-BEA3-88F1A87C648C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24B7B587-F7E7-4F56-BEA3-88F1A87C648C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24B7B587-F7E7-4F56-BEA3-88F1A87C648C}.Release|Any CPU.Build.0 = Release|Any CPU
{81426C52-CD04-4C22-85E7-F4FF4FB4E865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81426C52-CD04-4C22-85E7-F4FF4FB4E865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81426C52-CD04-4C22-85E7-F4FF4FB4E865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81426C52-CD04-4C22-85E7-F4FF4FB4E865}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E66BC41B-A020-4673-8A3F-1986A41479AD}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{B262A705-C1B2-4C1A-AE34-3B15119F609E} = {F29C9EB9-4B9A-4D8D-A776-6A849CA73DA6}
{D5566579-4803-4CF6-AC60-25D7EC075F6C} = {F29C9EB9-4B9A-4D8D-A776-6A849CA73DA6}
{D0389498-4624-4D02-93C5-69F02E678273} = {F29C9EB9-4B9A-4D8D-A776-6A849CA73DA6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E66BC41B-A020-4673-8A3F-1986A41479AD}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions src/TestingKeepAlive.Console/App.config
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.6.1" />
</startup>
</configuration>
120 changes: 120 additions & 0 deletions src/TestingKeepAlive.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Threading;

namespace TestingKeepAlive.Console
{

class Program
{
static void Main(string[] args)
{
var address = new Uri("http://localhost:52995/");

var writer = TextWriter.Synchronized(System.Console.Out);

var posts = new Thread(() =>
{
var iteration = 0;
while (true)
{
try
{
var request = CreateRequest(address);
request.Method = "POST";
request.ContentType = "application/json";

using (var str = request.GetRequestStream())
{
var bytes = Encoding.UTF8.GetBytes(@"{ ""Data"": [1, 2, 3] }");
str.Write(bytes, 0, bytes.Length);
}

using (var response = (HttpWebResponse)request.GetResponse())
{
writer.WriteLine("{0} {1}", ++iteration, response.StatusCode);
}
}
catch (WebException webException)
{
var stream = webException.Response?.GetResponseStream();
if (stream != null)
{
using (var reader = new StreamReader(stream))
{
writer.WriteLine(reader.ReadToEnd());
}
}

throw;
}
catch (Exception exception)
{
writer.WriteLine(exception);
throw;
}

Thread.Sleep(10);
}
});

var gets = new Thread(() =>
{
var iteration = 0;
while (true)
{
try
{
var request = CreateRequest(address);
request.Method = "GET";

using (var response = (HttpWebResponse)request.GetResponse())
{
writer.WriteLine("{0} {1}", ++iteration, response.StatusCode);
}
}
catch (WebException webException)
{
var stream = webException.Response?.GetResponseStream();
if (stream != null)
{
using (var reader = new StreamReader(stream))
{
writer.WriteLine(reader.ReadToEnd());
}
}

throw;
}
catch (Exception exception)
{
writer.WriteLine(exception);
throw;
}

Thread.Sleep(10);
}

});

posts.Start();
gets.Start();

posts.Join();
gets.Join();
}

static HttpWebRequest CreateRequest(Uri uri)
{
var r = WebRequest.CreateHttp(uri);

// Uncomment either of the following lines and the issue goes away
//r.KeepAlive = false;
//r.ProtocolVersion = HttpVersion.Version10;

return r;
}
}
}
36 changes: 36 additions & 0 deletions src/TestingKeepAlive.Console/Properties/AssemblyInfo.cs
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;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestingKeepAlive.Console")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestingKeepAlive.Console")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("81426c52-cd04-4c22-85e7-f4ff4fb4e865")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
53 changes: 53 additions & 0 deletions src/TestingKeepAlive.Console/TestingKeepAlive.Console.csproj
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>{81426C52-CD04-4C22-85E7-F4FF4FB4E865}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TestingKeepAlive.Console</RootNamespace>
<AssemblyName>TestingKeepAlive.Console</AssemblyName>
<TargetFrameworkVersion>v4.6.1</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>
47 changes: 47 additions & 0 deletions src/TestingKeepAlive.Web/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Linq;
using OpenRasta.Codecs.Newtonsoft.Json;
using OpenRasta.Configuration;
using OpenRasta.Hosting.Katana;
using OpenRasta.Web;
using Owin;

namespace TestingKeepAlive.Web
{
public class Config
{
public void Configuration(IAppBuilder app)
{
var openRastaConfiguration = new OpenRasta();

app.UseOpenRasta(openRastaConfiguration);
}

class OpenRasta : IConfigurationSource
{
public void Configure()
{
ResourceSpace.Has
.ResourcesOfType<Resource>()
.AtUri("/")
.HandledBy<Handler>()
.TranscodedBy<NewtonsoftJsonCodec>();
}
}

class Resource
{
public int[] Data { get; set; }
}

class Handler
{
public Resource Get() => new Resource
{
Data = Enumerable.Range(1, 10000).ToArray()
};

public OperationResult Post(Resource resource) => new OperationResult.NoContent();
}

}
}
38 changes: 38 additions & 0 deletions src/TestingKeepAlive.Web/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Owin;
using TestingKeepAlive.Web;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestingKeepAlive")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestingKeepAlive")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("24b7b587-f7e7-4f56-bea3-88f1a87c648c")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: OwinStartup(typeof(Config))]
Loading