Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rc fixes

  • Loading branch information...
commit 861e9effb7e2063d6f9560081942591de636347a 1 parent b897d0c
Sebastien Lambla serialseb authored
Showing with 8,684 additions and 453 deletions.
  1. +1 −1  build/dependencymanager.proj
  2. +2 −2 build/releasebuilder.targets
  3. BIN  lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.dll
  4. BIN  lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.pdb
  5. +3,182 −0 lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.xml
  6. BIN  lib/unity-1.2/Microsoft.Practices.Unity.dll
  7. BIN  lib/unity-1.2/Microsoft.Practices.Unity.pdb
  8. +2,977 −0 lib/unity-1.2/Microsoft.Practices.Unity.xml
  9. +61 −79 reports/nunit/.xml
  10. +1 −1  src/CommonInfo.cs
  11. +8 −0 src/aspnet/OpenRasta.Hosting.AspNet/OpenRastaHandler.cs
  12. +4 −0 src/core/OpenRasta.Tests.Integration/OpenRasta.Tests.Integration.csproj
  13. +59 −0 src/core/OpenRasta.Tests.Integration/Regressions/92.cs
  14. +11 −0 src/core/OpenRasta.Tests.Unit/Configuration/MetaModel_Specification.cs
  15. +17 −0 src/core/OpenRasta.Tests.Unit/IO/BoundaryStreamReader_Specification.cs
  16. +3 −1 src/core/OpenRasta.Tests.Unit/OpenRasta.Tests.Unit.csproj
  17. +9 −18 src/core/OpenRasta.Tests.Unit/OperationModel/Filters/UriParametersFilter_Specification.cs
  18. +2 −2 src/core/OpenRasta.Tests.Unit/OperationModel/Filters/operation_filter_context.cs
  19. +49 −0 src/core/OpenRasta.Tests.Unit/TestErrorCollector.cs
  20. +1 −0  src/core/OpenRasta.Tests.Unit/Web/Pipeline/Contributors/UriDecoratorsController_Specification.cs
  21. +2 −1  src/core/OpenRasta.Tests.Unit/Web/Pipeline/PipelineRunner_Specification.cs
  22. +68 −38 src/core/OpenRasta.Tests.Unit/Web/TemplatedUriResolver_Specification.cs
  23. +70 −0 src/core/OpenRasta.Tests.Unit/Web/UriDecorators/ContentTypeExtension_Specification.cs
  24. +5 −44 src/core/OpenRasta.Tests.Unit/{contributor_context.cs → openrasta_context.cs}
  25. +1 −1  src/core/OpenRasta/Codecs/application/xhtml+xml/OperationResultPage.cs
  26. +3 −4 src/core/OpenRasta/Codecs/multipart/form-data/AbstractMultipartFormDataCodec.cs
  27. +2 −2 src/core/OpenRasta/Configuration/Fluent/Implementation/CodecParentDefinition.cs
  28. +4 −0 src/core/OpenRasta/Error.cs
  29. +67 −61 src/core/OpenRasta/IO/BoundaryStreamReader.cs
  30. +11 −6 src/core/OpenRasta/IO/StreamExtensions.cs
  31. +4 −3 src/core/OpenRasta/OpenRasta.csproj
  32. +3 −3 src/core/OpenRasta/OperationModel/Filters/HttpMethodOperationFilter.cs
  33. +3 −4 src/core/OpenRasta/OperationModel/Filters/UriNameOperationFilter.cs
  34. +24 −17 src/core/OpenRasta/OperationModel/Filters/UriParametersFilter.cs
  35. +11 −5 src/core/OpenRasta/Pipeline/Contributors/DigestAuthorizerContributor.cs
  36. +1 −0  src/core/OpenRasta/Pipeline/Contributors/OperationCreatorContributor.cs
  37. +2 −4 src/core/OpenRasta/Pipeline/Contributors/ResourceTypeResolverContributor.cs
  38. +3 −1 src/core/OpenRasta/{ → Pipeline}/Diagnostics/PipelineLogSource.cs
  39. +22 −68 src/core/OpenRasta/Pipeline/PipelineRunner.cs
  40. +3 −12 src/core/OpenRasta/Web/IUriResolver.cs
  41. +16 −0 src/core/OpenRasta/Web/Internal/CommunicationContextExtensions.cs
  42. +54 −34 src/core/OpenRasta/Web/TemplatedUriResolver.cs
  43. +14 −0 src/core/OpenRasta/Web/TemplatedUriResolverLegacyExtensions.cs
  44. +27 −27 src/core/OpenRasta/Web/UriDecorators/ContentTypeExtensionUriDecorator.cs
  45. +3 −3 src/core/OpenRasta/Web/Wadl/WadlHandler.cs
  46. +3 −3 src/openbastard/OpenBastard.TestRunner/Scenarios/accessing_the_homepage.cs
  47. +65 −0 src/unity/OpenRasta.DI.Unity.Sample/Bootstrapper.cs
  48. +8 −0 src/unity/OpenRasta.DI.Unity.Sample/CustomLogger.cs
  49. +8 −0 src/unity/OpenRasta.DI.Unity.Sample/Default.aspx
  50. +10 −0 src/unity/OpenRasta.DI.Unity.Sample/Domain/Info.cs
  51. +37 −0 src/unity/OpenRasta.DI.Unity.Sample/Domain/InfoProvider.cs
  52. +118 −0 src/unity/OpenRasta.DI.Unity.Sample/OpenRasta.DI.Unity.Sample.csproj
  53. +35 −0 src/unity/OpenRasta.DI.Unity.Sample/Properties/AssemblyInfo.cs
  54. +26 −0 src/unity/OpenRasta.DI.Unity.Sample/Resources/InfoHandler.cs
  55. +95 −0 src/unity/OpenRasta.DI.Unity.Sample/Web.config
  56. +88 −0 src/unity/OpenRasta.DI.Unity.Tests.Unit/OpenRasta.DI.Unity.Tests.Unit.csproj
  57. +36 −0 src/unity/OpenRasta.DI.Unity.Tests.Unit/Properties/AssemblyInfo.cs
  58. +336 −0 src/unity/OpenRasta.DI.Unity.Tests.Unit/UnityDependencyResolver_Specification.cs
  59. +32 −0 src/unity/OpenRasta.DI.Unity.sln
  60. +19 −0 src/unity/OpenRasta.DI.Unity/Extensions/CycleDetector.cs
  61. +41 −0 src/unity/OpenRasta.DI.Unity/Extensions/InjectionPolicies.cs
  62. +106 −0 src/unity/OpenRasta.DI.Unity/Extensions/Policies/ConstructorSelectorPolicy.cs
  63. +11 −0 src/unity/OpenRasta.DI.Unity/Extensions/Policies/CycleDetectionPolicy.cs
  64. +76 −0 src/unity/OpenRasta.DI.Unity/Extensions/Policies/PropertySelectorPolicy.cs
  65. +25 −0 src/unity/OpenRasta.DI.Unity/Extensions/Policies/TypeToBeResolved.cs
  66. +17 −0 src/unity/OpenRasta.DI.Unity/Extensions/Policies/TypeTrackerPolicy.cs
  67. +45 −0 src/unity/OpenRasta.DI.Unity/Extensions/Strategies/CycleDetectionStrategy.cs
  68. +46 −0 src/unity/OpenRasta.DI.Unity/Extensions/Strategies/TypeRegistrationRequiredStrategy.cs
  69. +17 −0 src/unity/OpenRasta.DI.Unity/Extensions/TypeRegistrationRequired.cs
  70. +118 −0 src/unity/OpenRasta.DI.Unity/Extensions/TypeTracker.cs
  71. +87 −0 src/unity/OpenRasta.DI.Unity/OpenRasta.DI.Unity.csproj
  72. +52 −0 src/unity/OpenRasta.DI.Unity/PerRequestLifetimeManager.cs
  73. +36 −0 src/unity/OpenRasta.DI.Unity/Properties/AssemblyInfo.cs
  74. +16 −0 src/unity/OpenRasta.DI.Unity/UnityContainerExtensions.cs
  75. +234 −0 src/unity/OpenRasta.DI.Unity/UnityDependencyResolver.cs
  76. +1 −3 src/vside/templates/aspnet35/Configuration.cs
  77. +1 −0  src/vside/templates/aspnet35/OpenRasta.AspNet35.csproj
  78. +1 −2  src/vside/templates/aspnet35/Views/HomeView.Master
  79. +1 −1  src/vside/templates/aspnet35/Views/HomeView.aspx
  80. +17 −0 src/vside/templates/aspnet35/Views/Web.config
  81. +10 −2 src/vside/templates/aspnet35/default.aspx
2  build/dependencymanager.proj
View
@@ -12,7 +12,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(OpenRastaDirectory)' == '' And '$(FrameworkProfile)' != ''">
- <OpenRastaDirectory>$(RootPath)\bin\Release\net-$(FrameworkProfile)</OpenRastaDirectory>
+ <OpenRastaDirectory>$(RootPath)\bin\$(Configuration)\net-$(FrameworkProfile)</OpenRastaDirectory>
</PropertyGroup>
<Import Project="$(RootPath)\build\defaults.targets" />
4 build/releasebuilder.targets
View
@@ -81,7 +81,7 @@
</Math.Add>
<PropertyGroup>
<BuildVersion>$(BuildVersionMajor).$(BuildVersionMinor).$(BuildVersionBuild).$(BuildVersionRevision)</BuildVersion>
- <SetupFilePath Condition="'$(SetupFilePath)' == ''">$(RootPath)\bin\Release\OpenRasta-$(BuildVersion).exe</SetupFilePath>
+ <SetupFilePath Condition="'$(SetupFilePath)' == ''">$(RootPath)\bin\$(Configuration)\OpenRasta-$(BuildVersion).exe</SetupFilePath>
</PropertyGroup>
<AssemblyInfo CodeLanguage="CS"
OutputFile="$(CommonInfoPath)"
@@ -136,7 +136,7 @@
-->
<Target Name="CompileInstaller" DependsOnTargets="BuildAll" >
- <MSBuild Projects="@(Installer)" Targets="Rebuild" Properties="Platform=x86;Configuration=Release;WixToolPath=$(WixToolPath);WixTargetsPath=$(WixTargetsPath);WixTasksPath=$(WixTasksPath);WinExtDir=$(WinExtDir);BuildVersionMajor=$(BuildVersionMajor);BuildVersionMinor=$(BuildVersionMinor);BuildVersionBuild=$(BuildVersionBuild);BuildVersionRevision=$(BuildVersionRevision);BuildVersionBuildPrefix=$(BuildVersionBuildPrefix);PackageName=$(PackageName);ReleaseName=$(ReleaseName)">
+ <MSBuild Projects="@(Installer)" Targets="Rebuild" Properties="Platform=x86;Configuration=$(Configuration);WixToolPath=$(WixToolPath);WixTargetsPath=$(WixTargetsPath);WixTasksPath=$(WixTasksPath);WinExtDir=$(WinExtDir);BuildVersionMajor=$(BuildVersionMajor);BuildVersionMinor=$(BuildVersionMinor);BuildVersionBuild=$(BuildVersionBuild);BuildVersionRevision=$(BuildVersionRevision);BuildVersionBuildPrefix=$(BuildVersionBuildPrefix);PackageName=$(PackageName);ReleaseName=$(ReleaseName)">
<Output TaskParameter="TargetOutputs" ItemName="MSIFile" />
</MSBuild>
<Exec Condition="'$(SecureBuild)' == 'true'" Command="signtool.exe sign /f $(AuthenticodeKey) /p &quot;$(authenticode_key_password)&quot; /t $(TimeStampUrl) @(MSIFile)" />
BIN  lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.dll
View
Binary file not shown
BIN  lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.pdb
View
Binary file not shown
3,182 lib/unity-1.2/Microsoft.Practices.ObjectBuilder2.xml
View
3,182 additions, 0 deletions not shown
BIN  lib/unity-1.2/Microsoft.Practices.Unity.dll
View
Binary file not shown
BIN  lib/unity-1.2/Microsoft.Practices.Unity.pdb
View
Binary file not shown
2,977 lib/unity-1.2/Microsoft.Practices.Unity.xml
View
2,977 additions, 0 deletions not shown
140 reports/nunit/.xml
View
@@ -1,116 +1,98 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
-<test-results name="C:\src\caff\openrasta\trunk\bin\tmp\Release\net-35\OpenRasta.Tests.Integration\OpenRasta.Tests.Integration.dll" total="16" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2009-09-30" time="21:12:33">
- <environment nunit-version="2.5.1.9189" clr-version="2.0.50727.4918" os-version="Microsoft Windows NT 6.1.7100.0" platform="Win32NT" cwd="C:\src\caff\openrasta\trunk\build" machine-name="CHERENKOV" user="sebastien.lambla" user-domain="CAFFEINEIT" />
+<test-results name="C:\src\caff\openrasta\20rc\bin\tmp\Release\net-35\OpenBastard.TestRunner\OpenBastard.TestRunner.dll" total="28" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2009-11-04" time="11:53:01">
+ <environment nunit-version="2.5.1.9189" clr-version="2.0.50727.4927" os-version="Microsoft Windows NT 6.1.7100.0" platform="Win32NT" cwd="C:\src\caff\openrasta\20rc\build" machine-name="CHERENKOV" user="sebastien.lambla" user-domain="CAFFEINEIT" />
<culture-info current-culture="en-GB" current-uiculture="en-US" />
- <test-suite name="C:\src\caff\openrasta\trunk\bin\tmp\Release\net-35\OpenRasta.Tests.Integration\OpenRasta.Tests.Integration.dll" executed="True" success="True" time="20.155" asserts="0">
+ <test-suite name="C:\src\caff\openrasta\20rc\bin\tmp\Release\net-35\OpenBastard.TestRunner\OpenBastard.TestRunner.dll" executed="True" success="True" time="25.659" asserts="0">
<results>
- <test-suite name="DigestAuthentication_Specification" executed="True" success="True" time="3.806" asserts="0">
+ <test-suite name="HttpListener environment" executed="True" success="True" time="4.404" asserts="0">
<results>
- <test-suite name="when_using_the_correct_credentials" executed="True" success="True" time="3.806" asserts="0">
+ <test-suite name="accessing the homepage" executed="True" success="True" time="2.909" asserts="0">
<results>
- <test-case name="DigestAuthentication_Specification.when_using_the_correct_credentials.a_protected_resource_fails_with_unauthorized_error_when_no_credentials_are_provided" executed="True" success="True" time="1.139" asserts="1" />
- <test-case name="DigestAuthentication_Specification.when_using_the_correct_credentials.an_unprotected_resource_returns_200_even_with_invalid_credentials" executed="True" success="True" time="0.078" asserts="1" />
- <test-case name="DigestAuthentication_Specification.when_using_the_correct_credentials.the_user_authentication_is_successfull_on_URIs_with_encoded_characters" executed="True" success="True" time="0.218" asserts="1" />
- <test-case name="DigestAuthentication_Specification.when_using_the_correct_credentials.the_user_is_authenticated_and_a_200_response_is_returned" executed="True" success="True" time="0.000" asserts="1" />
+ <test-case name="OpenBastard.Scenarios.accessing_the_homepage.the_homepage_can_be_retrieved_using_xml" executed="True" success="True" time="2.896" asserts="3" />
</results>
</test-suite>
- </results>
- </test-suite>
- <test-suite name="HtmlForm_Specification" executed="True" success="True" time="1.919" asserts="0">
- <results>
- <test-suite name="when_receiving_an_entity_body" executed="True" success="True" time="1.919" asserts="0">
+ <test-suite name="manipulating users" executed="True" success="True" time="0.604" asserts="0">
<results>
- <test-case name="HtmlForm_Specification.when_receiving_an_entity_body.the_key_value_pairs_are_matched_to_string_parameters" executed="True" success="True" time="0.718" asserts="1" />
- <test-case name="HtmlForm_Specification.when_receiving_an_entity_body.the_pairs_are_matched_to_complex_parameters" executed="True" success="True" time="0.047" asserts="2" />
+ <test-case name="OpenBastard.Scenarios.manipulating_users.can_create_a_user" executed="True" success="True" time="0.604" asserts="4" />
</results>
</test-suite>
- </results>
- </test-suite>
- <test-suite name="Json_Specification" executed="True" success="True" time="2.839" asserts="0">
- <results>
- <test-suite name="when_sending_json_content" executed="True" success="True" time="2.839" asserts="0">
+ <test-suite name="uploading files" executed="True" success="True" time="0.139" asserts="0">
<results>
- <test-case name="Json_Specification.when_sending_json_content.the_content_is_parsed_as_the_correct_object_type" executed="True" success="True" time="1.607" asserts="3" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_a_complex_type" executed="True" success="True" time="0.068" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_app_octet_stream" executed="True" success="True" time="0.000" asserts="0" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_enumerable_multipart" executed="True" success="True" time="0.037" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_ifile" executed="True" success="True" time="0.018" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_file_with_specific_content_type" executed="True" success="True" time="0.013" asserts="10002" />
</results>
</test-suite>
</results>
</test-suite>
- <test-suite name="MultipartFormData_Specification" executed="True" success="True" time="1.763" asserts="0">
+ <test-suite name="IIS 7 - Classic Mode" executed="True" success="True" time="9.590" asserts="0">
<results>
- <test-suite name="when_the_request_contains_a_multipart_form_data_entity" executed="True" success="True" time="1.763" asserts="0">
+ <test-suite name="accessing the homepage" executed="True" success="True" time="6.262" asserts="0">
<results>
- <test-case name="MultipartFormData_Specification.when_the_request_contains_a_multipart_form_data_entity.the_multipart_entity_is_received" executed="True" success="True" time="0.562" asserts="1" />
+ <test-case name="OpenBastard.Scenarios.accessing_the_homepage.the_homepage_can_be_retrieved_using_xml" executed="True" success="True" time="6.262" asserts="3" />
</results>
</test-suite>
- </results>
- </test-suite>
- <test-suite name="MultipleThreads_Specification" executed="True" success="True" time="3.182" asserts="0">
- <results>
- <test-suite name="test_case" executed="False">
- <reason>
- <message><![CDATA[No suitable constructor was found]]></message>
- </reason>
+ <test-suite name="manipulating users" executed="True" success="True" time="0.519" asserts="0">
+ <results>
+ <test-case name="OpenBastard.Scenarios.manipulating_users.can_create_a_user" executed="True" success="True" time="0.519" asserts="4" />
+ </results>
</test-suite>
- <test-suite name="test_container" executed="True" success="True" time="3.167" asserts="0">
+ <test-suite name="uploading files" executed="True" success="True" time="0.125" asserts="0">
<results>
- <test-case name="MultipleThreads_Specification.test_container.testing_multiple_concurrent_requests" executed="True" success="True" time="1.919" asserts="2000">
- <properties>
- <property name="APARTMENT_STATE" value="MTA" />
- </properties>
- </test-case>
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_a_complex_type" executed="True" success="True" time="0.061" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_app_octet_stream" executed="True" success="True" time="0.000" asserts="0" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_enumerable_multipart" executed="True" success="True" time="0.026" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_ifile" executed="True" success="True" time="0.018" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_file_with_specific_content_type" executed="True" success="True" time="0.017" asserts="10002" />
</results>
</test-suite>
</results>
</test-suite>
- <test-suite name="OpenRasta" executed="True" success="True" time="4.664" asserts="0">
+ <test-suite name="IIS 7 - Integrated Mode" executed="True" success="True" time="11.527" asserts="0">
<results>
- <test-suite name="Tests" executed="True" success="True" time="4.664" asserts="0">
+ <test-suite name="accessing the homepage" executed="True" success="True" time="8.138" asserts="0">
<results>
- <test-suite name="Integration" executed="True" success="True" time="4.664" asserts="0">
- <results>
- <test-suite name="Regressions" executed="True" success="True" time="2.137" asserts="0">
- <results>
- <test-suite name="Handlers_not_selected_correctly" executed="True" success="True" time="2.044" asserts="0">
- <results>
- <test-case name="OpenRasta.Tests.Integration.Regressions.Handlers_not_selected_correctly.the_handler_for_individual_items_is_selected" executed="True" success="True" time="0.686" asserts="2" />
- <test-case name="OpenRasta.Tests.Integration.Regressions.Handlers_not_selected_correctly.the_handler_with_the_most_attributes_is_selected" executed="True" success="True" time="0.140" asserts="4" />
- </results>
- </test-suite>
- <test-suite name="when_httplistenerhost_resolveraccessor_is_accessed_multiple_times" executed="True" success="True" time="0.094" asserts="0">
- <results>
- <test-case name="OpenRasta.Tests.Integration.Regressions.when_httplistenerhost_resolveraccessor_is_accessed_multiple_times.the_results_should_be_the_same_instance" executed="True" success="True" time="0.094" asserts="1" />
- </results>
- </test-suite>
- </results>
- </test-suite>
- <test-suite name="server_context" executed="False">
- <reason>
- <message><![CDATA[OpenRasta.Tests.Integration.server_context is an abstract class]]></message>
- </reason>
- </test-suite>
- <test-suite name="UriDecorators" executed="True" success="True" time="2.527" asserts="0">
- <results>
- <test-suite name="when_file_extensions_are_activated" executed="True" success="True" time="2.527" asserts="0">
- <results>
- <test-case name="OpenRasta.Tests.Integration.UriDecorators.when_file_extensions_are_activated.a_request_on_the_extension_uri_returns_the_correct_entity" executed="True" success="True" time="1.061" asserts="1" />
- <test-case name="OpenRasta.Tests.Integration.UriDecorators.when_file_extensions_are_activated.a_request_on_the_generic_uri_returns_the_correct_entity" executed="True" success="True" time="0.062" asserts="1" />
- </results>
- </test-suite>
- </results>
- </test-suite>
- </results>
- </test-suite>
+ <test-case name="OpenBastard.Scenarios.accessing_the_homepage.the_homepage_can_be_retrieved_using_xml" executed="True" success="True" time="8.138" asserts="3" />
+ </results>
+ </test-suite>
+ <test-suite name="manipulating users" executed="True" success="True" time="0.570" asserts="0">
+ <results>
+ <test-case name="OpenBastard.Scenarios.manipulating_users.can_create_a_user" executed="True" success="True" time="0.570" asserts="4" />
+ </results>
+ </test-suite>
+ <test-suite name="uploading files" executed="True" success="True" time="0.135" asserts="0">
+ <results>
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_a_complex_type" executed="True" success="True" time="0.068" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_app_octet_stream" executed="True" success="True" time="0.000" asserts="0" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_enumerable_multipart" executed="True" success="True" time="0.028" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_ifile" executed="True" success="True" time="0.019" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_file_with_specific_content_type" executed="True" success="True" time="0.018" asserts="10002" />
</results>
</test-suite>
</results>
</test-suite>
- <test-suite name="TextPlain_Specification" executed="True" success="True" time="1.888" asserts="0">
+ <test-suite name="In memory environment" executed="True" success="True" time="0.120" asserts="0">
<results>
- <test-suite name="when_using_text_plain" executed="True" success="True" time="1.888" asserts="0">
+ <test-suite name="accessing the homepage" executed="True" success="True" time="0.017" asserts="0">
+ <results>
+ <test-case name="OpenBastard.Scenarios.accessing_the_homepage.the_homepage_can_be_retrieved_using_xml" executed="True" success="True" time="0.017" asserts="3" />
+ </results>
+ </test-suite>
+ <test-suite name="manipulating users" executed="True" success="True" time="0.006" asserts="0">
+ <results>
+ <test-case name="OpenBastard.Scenarios.manipulating_users.can_create_a_user" executed="True" success="True" time="0.005" asserts="4" />
+ </results>
+ </test-suite>
+ <test-suite name="uploading files" executed="True" success="True" time="0.070" asserts="0">
<results>
- <test-case name="TextPlain_Specification.when_using_text_plain.the_request_is_matched_to_the_parameter" executed="True" success="True" time="0.655" asserts="2" />
- <test-case name="TextPlain_Specification.when_using_text_plain.the_response_is_formatted_in_text_plain" executed="True" success="True" time="0.016" asserts="2" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_a_complex_type" executed="True" success="True" time="0.018" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_app_octet_stream" executed="True" success="True" time="0.000" asserts="0" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_enumerable_multipart" executed="True" success="True" time="0.015" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_a_file_as_an_ifile" executed="True" success="True" time="0.015" asserts="10002" />
+ <test-case name="OpenBastard.Scenarios.uploading_files.can_upload_file_with_specific_content_type" executed="True" success="True" time="0.015" asserts="10002" />
</results>
</test-suite>
</results>
2  src/CommonInfo.cs
View
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.4918
+// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
8 src/aspnet/OpenRasta.Hosting.AspNet/OpenRastaHandler.cs
View
@@ -45,6 +45,10 @@ public void ReleaseHandler(IHttpHandler handler)
public class OpenRastaRewriterHandler : IHttpHandler
{
+ public OpenRastaRewriterHandler()
+ {
+ Log = NullLogger.Instance;
+ }
public bool IsReusable
{
get { return true; }
@@ -64,6 +68,10 @@ public void ProcessRequest(HttpContext context)
public class OpenRastaIntegratedHandler : IHttpHandler
{
+ public OpenRastaIntegratedHandler()
+ {
+ Log = NullLogger.Instance;
+ }
public bool IsReusable
{
get { return true; }
4 src/core/OpenRasta.Tests.Integration/OpenRasta.Tests.Integration.csproj
View
@@ -62,6 +62,7 @@
<Compile Include="..\..\CommonInfo.cs">
<Link>Properties\CommonInfo.cs</Link>
</Compile>
+ <Compile Include="Regressions\92.cs" />
<Compile Include="Codecs\HtmlForm_Specification.cs" />
<Compile Include="Codecs\Json_Specification.cs" />
<Compile Include="Codecs\MultipartFormData_Specification.cs" />
@@ -96,6 +97,9 @@
<Name>OpenRasta.Testing</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Binding\" />
+ </ItemGroup>
<Import Project="..\..\..\build\defaults.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
59 src/core/OpenRasta.Tests.Integration/Regressions/92.cs
View
@@ -0,0 +1,59 @@
+using System;
+using System.Net;
+using System.ServiceModel.Syndication;
+using System.Text;
+using System.Xml;
+using NUnit.Framework;
+using OpenRasta.Codecs;
+using OpenRasta.Configuration;
+using OpenRasta.Configuration.Fluent;
+using OpenRasta.Data;
+using OpenRasta.Testing;
+using OpenRasta.Web;
+
+namespace OpenRasta.Tests.Integration.Regressions
+{
+ public class changeset_not_hydrated_properly : server_context
+ {
+ public changeset_not_hydrated_properly()
+ {
+ ConfigureServer(() =>
+ {
+ ResourceSpace.Has.ResourcesOfType<Product>()
+ .AtUri("/products/{name}")
+ .HandledBy<ProductHandler>()
+ .AsXmlDataContract();
+ });
+ }
+
+ protected SyndicationFeed Feed { get; set; }
+
+ protected SyndicationItem Item { get; set; }
+
+ [Test]
+ public void the_handler_for_individual_items_is_selected()
+ {
+ given_request("POST", "/products/moq",Encoding.UTF8.GetBytes("Description=The+description+of+MOQ"), MediaType.ApplicationXWwwFormUrlencoded);
+
+ when_reading_response();
+
+ TheResponse.StatusCode.ShouldBe(HttpStatusCode.OK);
+ }
+ }
+
+ public class ProductHandler
+ {
+ public OperationResult Post(string name, ChangeSet<Product> product)
+ {
+ if (name == "moq" && product.Changes.Count == 1)
+ return new OperationResult.OK();
+ return new OperationResult.MethodNotAllowed();
+ }
+ }
+
+ public class Product
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ }
+}
11 src/core/OpenRasta.Tests.Unit/Configuration/MetaModel_Specification.cs
View
@@ -289,7 +289,17 @@ public void can_add_a_codec_by_type_instance()
FirstRegistration.Codecs[0].CodecType.ShouldBe<CustomerCodec>();
});
}
+ [Test]
+ public void can_add_a_codec_configuration()
+ {
+ ExecuteTest(parent =>
+ {
+ var configurationObject = new object();
+ parent.TranscodedBy(typeof(CustomerCodec),configurationObject);
+ FirstRegistration.Codecs[0].Configuration.ShouldBe(configurationObject);
+ });
+ }
[Test]
public void can_add_a_specific_media_type_for_a_codec()
{
@@ -383,6 +393,7 @@ public void cannot_register_codec_not_implementing_icodec()
void ExecuteTest(Action<ICodecParentDefinition> test)
{
test(ResourceSpaceHas.ResourcesOfType<Frodo>().AtUri("/theshrine").HandledBy<CustomerHandler>());
+ MetaModel.ResourceRegistrations.Clear();
test(ResourceSpaceHas.ResourcesOfType<Frodo>().WithoutUri);
}
}
17 src/core/OpenRasta.Tests.Unit/IO/BoundaryStreamReader_Specification.cs
View
@@ -9,6 +9,7 @@
#endregion
using System;
+using System.IO;
using System.Text;
using NUnit.Framework;
using OpenRasta.IO;
@@ -197,7 +198,23 @@ public void skipping_twice_reads_the_thrid_entity()
Reader.SeekToNextPart();
Reader.GetNextPart().ReadToEnd().ShouldBe(TextInASCII("content3"));
}
+ [Test]
+ public void reading_over_truncated_values_doesnt_corrupt_the_stream()
+ {
+ byte[] content = new byte[9000];
+ for (int i = 0; i < content.Length; i++)
+ {
+ content[i] = (byte)(i % 255);
+ }
+ content[4095] = 13;
+ GivenAMemoryStreamContaining(TextInASCII("--boundary\r\n"), content, TextInASCII("\r\n--boundary--"));
+
+ GivenABoundaryStreamReader("boundary");
+ Reader.SeekToNextPart();
+
+ Reader.GetNextPart().ReadToEnd().ShouldBe(content);
+ }
[Test]
public void the_buffer_of_the_reader_must_be_big_enough_to_seek_for_a_boundary()
{
4 src/core/OpenRasta.Tests.Unit/OpenRasta.Tests.Unit.csproj
View
@@ -97,6 +97,7 @@
<Compile Include="IO\ByteArrayExtension_Specification.cs" />
<Compile Include="IO\DeterministicStreamWriter_Specification.cs" />
<Compile Include="IO\LengthTrackingStream_Specification.cs" />
+ <Compile Include="openrasta_context.cs" />
<Compile Include="OperationModel\CodecSelectors\RequestCodecSelector_Specification.cs" />
<Compile Include="OperationModel\Filters\HttpMethodOperationFilter_Specification.cs" />
<Compile Include="OperationModel\Filters\operation_filter_context.cs" />
@@ -136,7 +137,7 @@
<Compile Include="IO\MultipartReader_Specification.cs" />
<Compile Include="Codecs\CodecRepository_Specification.cs" />
<Compile Include="TypeSystem\Extensions_Specification.cs" />
- <Compile Include="contributor_context.cs" />
+ <Compile Include="TestErrorCollector.cs" />
<Compile Include="Web\IUriResolverExtensions_Specification.cs" />
<Compile Include="Web\Markup\FormElement_Specification.cs" />
<Compile Include="Web\Markup\IIframeModule_Specification.cs" />
@@ -165,6 +166,7 @@
<Compile Include="Web\Reflection_Specification.cs" />
<Compile Include="Web\TemplatedUriResolver_Specification.cs" />
<Compile Include="Web\MediaType_Specification.cs" />
+ <Compile Include="Web\UriDecorators\ContentTypeExtension_Specification.cs" />
<Compile Include="Web\WhenUsingCollectionExtensions.cs" />
</ItemGroup>
<ItemGroup Condition="'$(MergedAssemblyName)' == ''">
27 src/core/OpenRasta.Tests.Unit/OperationModel/Filters/UriParametersFilter_Specification.cs
View
@@ -24,8 +24,11 @@ public void all_operations_are_selected()
when_filtering_operations();
FilteredOperations.ShouldHaveSameElementsAs(Operations);
+ Errors.Errors.Count.ShouldBe(0);
+
}
}
+
public class when_there_is_one_uri_parameter_list : uriparameters_context
{
[Test]
@@ -38,6 +41,8 @@ public void an_operation_having_all_parameters_is_selected()
when_filtering_operations();
FilteredOperations.ShouldHaveCountOf(1).First().Name.ShouldBe("Post");
+ Errors.Errors.Count.ShouldBe(0);
+
}
[Test]
public void operations_not_having_the_correct_parameter_is_excluded()
@@ -60,6 +65,8 @@ public void operations_with_the_wrong_parameter_type_are_not_selected()
when_filtering_operations();
FilteredOperations.ShouldHaveCountOf(0);
+ Errors.Errors.Count.ShouldNotBe(0);
+
}
}
}
@@ -70,12 +77,11 @@ protected override void SetUp()
base.SetUp();
Context.PipelineData.SelectedResource = new UriRegistration(null,null);// { UriTemplateParameters = new List<NameValueCollection>() };
}
- protected FakeErrorCollector ErrorCollector { get; set; }
protected override UriParametersFilter create_filter()
{
- ErrorCollector = new FakeErrorCollector();
- return new UriParametersFilter(Context, ErrorCollector);
+
+ return new UriParametersFilter(Context, Errors);
}
}
@@ -90,19 +96,4 @@ public object Post(int index, string content)
return null;
}
}
- public class FakeErrorCollector : IErrorCollector
- {
- public FakeErrorCollector()
- {
- Errors = new List<Error>();
- }
- public void AddServerError(Error error)
- {
-
- Errors.Add(error);
-
- }
-
- public IList<Error> Errors { get; set; }
- }
}
4 src/core/OpenRasta.Tests.Unit/OperationModel/Filters/operation_filter_context.cs
View
@@ -34,12 +34,12 @@ protected void given_operations()
protected void when_filtering_operations()
{
- FilteredOperations = Filter.Process(Operations);
+ FilteredOperations = Filter.Process(Operations).ToList();
}
protected void given_operation_value(string methodName, string parameterName, object parameterValue)
{
- Enumerable.First<IOperation>(Operations, x => x.Name == methodName).Inputs.Required().First(x => x.Member.Name == parameterName).Binder.SetInstance(parameterValue)
+ Operations.First(x => x.Name == methodName).Inputs.Required().First(x => x.Member.Name == parameterName).Binder.SetInstance(parameterValue)
.ShouldBeTrue();
}
}
49 src/core/OpenRasta.Tests.Unit/TestErrorCollector.cs
View
@@ -0,0 +1,49 @@
+#region License
+/* Authors:
+ * Sebastien Lambla (seb@serialseb.com)
+ * Copyright:
+ * (C) 2007-2009 Caffeine IT & naughtyProd Ltd (http://www.caffeine-it.com)
+ * License:
+ * This file is distributed under the terms of the MIT License found at the end of this file.
+ */
+#endregion
+
+using System.Collections.Generic;
+using OpenRasta.Diagnostics;
+using OpenRasta.Hosting;
+
+namespace OpenRasta.Tests
+{
+ public class TestErrorCollector : IErrorCollector
+ {
+ public IList<Error> Errors { get; private set; }
+
+ public TestErrorCollector()
+ {
+ Errors = new List<Error>();
+ }
+ public void AddServerError(Error error)
+ {
+ Errors.Add(error);
+ }
+ }
+}
+
+#region Full license
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#endregion
1  src/core/OpenRasta.Tests.Unit/Web/Pipeline/Contributors/UriDecoratorsController_Specification.cs
View
@@ -43,6 +43,7 @@ public void processing_a_decorator_changes_the_request_url()
RemoveLastHello.ApplyWasCalled.ShouldBeTrue();
Context.Request.Uri.ShouldBe(new Uri("http://localhost/segment"));
}
+
}
public class RemoveLastHello : RemovingWordAtEndOfSegmentDecorator
3  src/core/OpenRasta.Tests.Unit/Web/Pipeline/PipelineRunner_Specification.cs
View
@@ -16,6 +16,7 @@
using OpenRasta.Diagnostics;
using OpenRasta.Hosting.InMemory;
using OpenRasta.Pipeline.Contributors;
+using OpenRasta.Pipeline.Diagnostics;
using OpenRasta.Testing;
using OpenRasta.Web;
using OpenRasta.Pipeline;
@@ -207,7 +208,7 @@ protected IPipeline CreatePipeline(params Type[] contributorTypes)
resolver.AddDependency<IPipelineContributor, BootstrapperContributor>();
foreach (var type in contributorTypes)
resolver.AddDependency(typeof(IPipelineContributor), type, DependencyLifetime.Singleton);
- var runner = new PipelineRunner(resolver) { Log = new TraceSourceLogger() };
+ var runner = new PipelineRunner(resolver) { PipelineLog = new TraceSourceLogger<PipelineLogSource>() };
runner.Initialize();
return runner;
}
106 src/core/OpenRasta.Tests.Unit/Web/TemplatedUriResolver_Specification.cs
View
@@ -13,6 +13,7 @@
using System.Collections.Specialized;
using System.Globalization;
using NUnit.Framework;
+using OpenRasta;
using OpenRasta.Testing;
using OpenRasta.Tests.Unit.Fakes;
using OpenRasta.Web;
@@ -20,35 +21,37 @@
namespace TemplatedUriResolver_Specification
{
[TestFixture]
- public class when_binding_uris_by_type : context
+ public class creating_uris : context
{
- [SetUp]
- public void before_each_behavior()
- {
- ThenTheResult = null;
- Resolver = new TemplatedUriResolver();
- }
TemplatedUriResolver Resolver;
Uri ThenTheResult;
- void WhenResolvingVariablesFor<T1>(NameValueCollection nameValueCollection)
+ [Test]
+ public void a_uri_by_name_is_found()
{
- ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof (T1), nameValueCollection);
+ given_uri_mapping("/location1", typeof(IConvertible), CultureInfo.CurrentCulture, null);
+ given_uri_mapping("/location2", typeof(IConvertible), CultureInfo.CurrentCulture, "location2");
+
+ when_creating_uri<IConvertible>("location2", null);
+
+ ThenTheResult.ShouldBe("http://localhost/location2");
}
- void WhenResolvingVariablesFor<T1>(string uriName, NameValueCollection nameValueCollection)
+
+ [SetUp]
+ public void before_each_behavior()
{
- ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), uriName,nameValueCollection);
+ ThenTheResult = null;
+ Resolver = new TemplatedUriResolver();
}
- void GivenThatTheResolverHas(string uri, Type type, CultureInfo cultureInfo, string alias) { Resolver.AddUriMapping(uri, type, cultureInfo, alias); }
[Test]
public void the_correct_values_replace_the_variable_declarations()
{
- GivenThatTheResolverHas("/test2/{variable2}", typeof(object), CultureInfo.CurrentCulture, null);
- GivenThatTheResolverHas("/test/{variable1}", typeof(object), CultureInfo.CurrentCulture, null);
+ given_uri_mapping("/test2/{variable2}", typeof(object), CultureInfo.CurrentCulture, null);
+ given_uri_mapping("/test/{variable1}", typeof(object), CultureInfo.CurrentCulture, null);
- WhenResolvingVariablesFor<object>(new NameValueCollection {{"variable1", "injected1"}});
+ when_creating_uri<object>(new NameValueCollection { { "variable1", "injected1" } });
ThenTheResult.ToString().ShouldBe("http://localhost/test/injected1");
}
@@ -56,9 +59,9 @@ public void the_correct_values_replace_the_variable_declarations()
[Test]
public void the_generated_uri_is_correct_for_generic_types()
{
- GivenThatTheResolverHas("/test/{variable1}", typeof (IList<object>), CultureInfo.CurrentCulture, null);
+ given_uri_mapping("/test/{variable1}", typeof(IList<object>), CultureInfo.CurrentCulture, null);
- WhenResolvingVariablesFor<IList<object>>(new NameValueCollection {{"variable1", "injected1"}});
+ when_creating_uri<IList<object>>(new NameValueCollection { { "variable1", "injected1" } });
ThenTheResult.ToString().ShouldBe("http://localhost/test/injected1");
}
@@ -66,49 +69,79 @@ public void the_generated_uri_is_correct_for_generic_types()
[Test]
public void the_generated_uri_is_correct_when_injecting_in_query_string_variables()
{
- GivenThatTheResolverHas("/test?query={variable1}", typeof (IList<object>), CultureInfo.CurrentCulture,
+ given_uri_mapping("/test?query={variable1}",
+ typeof(IList<object>),
+ CultureInfo.CurrentCulture,
null);
- WhenResolvingVariablesFor<IList<object>>(new NameValueCollection {{"variable1", "injected1"}});
+ when_creating_uri<IList<object>>(new NameValueCollection { { "variable1", "injected1" } });
ThenTheResult.ToString().ShouldBe("http://localhost/test?query=injected1");
}
+
[Test]
- public void a_uri_by_name_is_found()
+ public void uris_with_names_are_not_selected_by_default()
{
- GivenThatTheResolverHas("/location1", typeof(IConvertible), CultureInfo.CurrentCulture, null);
- GivenThatTheResolverHas("/location2", typeof(IConvertible), CultureInfo.CurrentCulture, "location2");
+ given_uri_mapping("/location1", typeof(IConvertible), CultureInfo.CurrentCulture, null);
+ given_uri_mapping("/location2", typeof(IConvertible), CultureInfo.CurrentCulture, "location2");
- WhenResolvingVariablesFor<IConvertible>("location2",null);
+ when_creating_uri<IConvertible>(null);
- ThenTheResult.ShouldBe("http://localhost/location2");
+ ThenTheResult.ShouldBe("http://localhost/location1");
}
[Test]
- public void uris_with_names_are_not_selected_by_default()
+ public void uris_with_non_matching_templates_because_the_nvc_is_null_are_ignored()
{
- GivenThatTheResolverHas("/location1", typeof(IConvertible), CultureInfo.CurrentCulture, null);
- GivenThatTheResolverHas("/location2", typeof(IConvertible), CultureInfo.CurrentCulture, "location2");
+ given_uri_mapping("/theshire", typeof(Frodo), CultureInfo.InvariantCulture, null);
+ given_uri_mapping("/theshire/{housename}", typeof(Frodo), CultureInfo.InvariantCulture, null);
- WhenResolvingVariablesFor<IConvertible>(null);
+ when_creating_uri<Frodo>(null);
- ThenTheResult.ShouldBe("http://localhost/location1");
+ ThenTheResult.ShouldBe("http://localhost/theshire");
}
[Test]
- public void uris_with_non_matching_templates_because_the_nvc_is_null_are_ignored()
+ public void uris_are_generated_correctly_when_base_uri_has_trailing_slash()
{
- GivenThatTheResolverHas("/theshire", typeof(Frodo), CultureInfo.InvariantCulture, null);
- GivenThatTheResolverHas("/theshire/{housename}", typeof(Frodo), CultureInfo.InvariantCulture, null);
+ given_uri_mapping("/theshire", typeof(Frodo), CultureInfo.InvariantCulture, null);
- WhenResolvingVariablesFor<Frodo>(null);
+ when_creating_uri<Frodo>("http://localhost/lotr/".ToUri(),null);
- ThenTheResult.ShouldBe("http://localhost/theshire");
+ ThenTheResult.ShouldBe("http://localhost/lotr/theshire");
+ }
+
+ [Test]
+ public void uris_are_generated_correctly_when_base_uri_hasnt_got_trailing_slash()
+ {
+ given_uri_mapping("/theshire", typeof(Frodo), CultureInfo.InvariantCulture, null);
+
+ when_creating_uri<Frodo>("http://localhost/lotr".ToUri(), null);
+
+ ThenTheResult.ShouldBe("http://localhost/lotr/theshire");
+ }
+ void when_creating_uri<T>(Uri baseUri, NameValueCollection templateParameters)
+ {
+ ThenTheResult = Resolver.CreateUriFor(baseUri, typeof(T), templateParameters);
+ }
+
+ void given_uri_mapping(string uri, Type type, CultureInfo cultureInfo, string alias)
+ {
+ Resolver.Add(new UriRegistration(uri, type, alias, cultureInfo));
+ }
+
+ void when_creating_uri<T1>(NameValueCollection nameValueCollection)
+ {
+ ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), nameValueCollection);
+ }
+
+ void when_creating_uri<T1>(string uriName, NameValueCollection nameValueCollection)
+ {
+ ThenTheResult = Resolver.CreateUriFor(new Uri("http://localhost"), typeof(T1), uriName, nameValueCollection);
}
}
}
#region Full license
-//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
@@ -116,10 +149,8 @@ public void uris_with_non_matching_templates_because_the_nvc_is_null_are_ignored
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
-//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
-//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -127,5 +158,4 @@ public void uris_with_non_matching_templates_because_the_nvc_is_null_are_ignored
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
#endregion
70 src/core/OpenRasta.Tests.Unit/Web/UriDecorators/ContentTypeExtension_Specification.cs
View
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ApplicationXWwwUrlformEncodedCodec_Specification;
+using NUnit.Framework;
+using OpenRasta.Codecs;
+using OpenRasta.Testing;
+using OpenRasta.Web;
+using OpenRasta.TypeSystem;
+using OpenRasta.Web.UriDecorators;
+
+namespace OpenRasta.Tests.Unit.Web.UriDecorators
+{
+ public class when_rewriting_a_uri_with_extension : context.content_type_extension
+ {
+ [Test]
+ public void the_rewritten_uri_is_relative_to_the_app_base()
+ {
+ given_resource<Customer>("/customer/{id}");
+ given_request_uri("http://localhost/vdir/customer/1.xml");
+ given_context_applicationBase("http://localhost/vdir");
+
+ when_parsing();
+ ParsingResult.ShouldBeTrue();
+ ProcessedUri.ShouldBe("http://localhost/vdir/customer/1");
+
+ when_applying();
+ Context.PipelineData.ResponseCodec.CodecType.ShouldBe<XmlCodec>();
+ Context.Response.Entity.ContentType.ShouldBe(MediaType.Xml);
+
+ }
+
+ }
+ namespace context
+ {
+ public class content_type_extension : openrasta_context
+ {
+ protected Uri ProcessedUri;
+
+ public content_type_extension()
+ {
+
+ }
+ protected void given_resource<T>(string template)
+ {
+ var resourceKey = TypeSystem.FromClr<T>();
+ UriResolver.Add(new UriRegistration(template, resourceKey));
+ Codecs.Add(new CodecRegistration(typeof(XmlCodec),
+ resourceKey,
+ false,
+ MediaType.Xml,
+ new[]{"xml"},null,false));
+ }
+ protected void when_parsing()
+ {
+ Parser = Parser ?? new ContentTypeExtensionUriDecorator(Context, UriResolver, Codecs, TypeSystem);
+ ParsingResult = Parser.Parse(Request.Uri, out ProcessedUri);
+ }
+ protected void when_applying()
+ {
+ Parser.Apply();
+ }
+
+ protected bool ParsingResult { get; set; }
+
+ protected ContentTypeExtensionUriDecorator Parser { get; set; }
+ }
+ }
+}
49 src/core/OpenRasta.Tests.Unit/contributor_context.cs → src/core/OpenRasta.Tests.Unit/openrasta_context.cs
View
@@ -1,13 +1,3 @@
-#region License
-/* Authors:
- * Sebastien Lambla (seb@serialseb.com)
- * Copyright:
- * (C) 2007-2009 Caffeine IT & naughtyProd Ltd (http://www.caffeine-it.com)
- * License:
- * This file is distributed under the terms of the MIT License found at the end of this file.
- */
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
@@ -19,14 +9,13 @@
using OpenRasta.DI;
using OpenRasta.Diagnostics;
using OpenRasta.Handlers;
-using OpenRasta.Hosting;
using OpenRasta.Hosting.InMemory;
+using OpenRasta.Pipeline;
using OpenRasta.Security;
using OpenRasta.Testing;
using OpenRasta.TypeSystem;
using OpenRasta.TypeSystem.ReflectionBased;
using OpenRasta.Web;
-using OpenRasta.Pipeline;
namespace OpenRasta.Tests
{
@@ -47,7 +36,7 @@ protected ICodecRepository Codecs
get { return Resolver.Resolve<ICodecRepository>(); }
}
- protected ICommunicationContext Context { get; private set; }
+ protected InMemoryCommunicationContext Context { get; private set; }
protected bool IsContributorExecuted { get; set; }
protected IPipeline Pipeline { get; private set; }
@@ -334,38 +323,10 @@ protected void given_request_uriName(string uriName)
Context.PipelineData.SelectedResource = new UriRegistration(r.UriTemplate,r.ResourceKey,uriName,r.UriCulture);
}
}
- }
- public class TestErrorCollector : IErrorCollector
- {
- public IList<Error> Errors { get; private set; }
-
- public TestErrorCollector()
- {
- Errors = new List<Error>();
- }
- public void AddServerError(Error error)
+ protected void given_context_applicationBase(string appBasePath)
{
- Errors.Add(error);
+ Context.ApplicationBaseUri = new Uri(appBasePath,UriKind.Absolute);
}
}
-}
-
-#region Full license
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#endregion
+}
2  src/core/OpenRasta/Codecs/application/xhtml+xml/OperationResultPage.cs
View
@@ -5,7 +5,7 @@
using OpenRasta.Web;
using OpenRasta.Web.Markup.Elements;
-namespace OpenRasta.Codecs.application.xhtml_xml
+namespace OpenRasta.Codecs
{
public class OperationResultPage : Element
{
7 src/core/OpenRasta/Codecs/multipart/form-data/AbstractMultipartFormDataCodec.cs
View
@@ -149,9 +149,9 @@ static Stream CreateTempFile(out string filePath)
using (var fileStream = CreateTempFile(out filePath))
{
memoryStream.Position = 0;
- memoryStream.CopyTo(fileStream);
+ var memoryStreamLength = memoryStream.CopyTo(fileStream);
fileStream.Write(_buffer, 0, lastRead);
- requestPart.Stream.CopyTo(fileStream);
+ var leftoverLength = requestPart.Stream.CopyTo(fileStream);
}
memoryStream = null;
requestPart.SwapStream(filePath);
@@ -166,8 +166,7 @@ static Stream CreateTempFile(out string filePath)
}
var listOfEntities = formData[requestPart.Headers.ContentDisposition.Name]
??
- (formData[requestPart.Headers.ContentDisposition.Name] =
- new List<IMultipartHttpEntity>());
+ (formData[requestPart.Headers.ContentDisposition.Name] = new List<IMultipartHttpEntity>());
if (requestPart.ContentType == null)
requestPart.ContentType = MediaType.TextPlain;
listOfEntities.Add(requestPart);
4 src/core/OpenRasta/Configuration/Fluent/Implementation/CodecParentDefinition.cs
View
@@ -14,12 +14,12 @@ public CodecParentDefinition(ResourceDefinition registration)
public ICodecDefinition TranscodedBy<TCodec>(object configuration) where TCodec : ICodec
{
- return _resourceDefinition.TranscodedBy<TCodec>();
+ return _resourceDefinition.TranscodedBy<TCodec>(configuration);
}
public ICodecDefinition TranscodedBy(Type type, object configuration)
{
- return _resourceDefinition.TranscodedBy(type);
+ return _resourceDefinition.TranscodedBy(type, configuration);
}
}
}
4 src/core/OpenRasta/Error.cs
View
@@ -7,5 +7,9 @@ public class Error
public string Title { get; set; }
public string Message { get; set; }
public Exception Exception { get; set; }
+ public override string ToString()
+ {
+ return "{0}\r\nMessage:\r\n{1}\r\n".With(Title, Message) + Exception != null ? "Exception:\r\n{0}".With(Exception) : string.Empty;
+ }
}
}
128 src/core/OpenRasta/IO/BoundaryStreamReader.cs
View
@@ -1,5 +1,4 @@
#region License
-
/* Authors:
* Sebastien Lambla (seb@serialseb.com)
* Copyright:
@@ -22,11 +21,9 @@ public class BoundaryStreamReader
readonly byte[] _beginBoundary;
readonly string _beginBoundaryAsString;
readonly byte[] _localBuffer;
- readonly byte[] crLf = new byte[] {13, 10};
- byte[] _firstBoundary;
+ readonly byte[] _newLine = new byte[] { 13, 10 };
int _localBufferLength;
BoundarySubStream _previousStream;
- public ILogger Log { get; set; }
public BoundaryStreamReader(string boundary, Stream baseStream)
: this(boundary, baseStream, Encoding.ASCII)
@@ -55,7 +52,7 @@ public BoundaryStreamReader(string boundary, Stream baseStream, Encoding streamE
// or that it should depend on the source page.
// Need to test what browsers do in the wild.
Encoding = streamEncoding;
- _firstBoundary = Encoding.GetBytes("--" + boundary);
+ Encoding.GetBytes("--" + boundary);
_beginBoundary = Encoding.GetBytes("\r\n--" + boundary);
_localBuffer = new byte[bufferLength];
_beginBoundaryAsString = "--" + boundary;
@@ -67,6 +64,7 @@ public BoundaryStreamReader(string boundary, Stream baseStream, Encoding streamE
public bool AtPreamble { get; private set; }
public Stream BaseStream { get; private set; }
public Encoding Encoding { get; private set; }
+ public ILogger Log { get; set; }
public Stream GetNextPart()
{
@@ -75,7 +73,7 @@ public Stream GetNextPart()
SkipPreamble();
if (AtEndBoundary)
return null;
- TerminateExistingStream(true);
+ TerminateExistingStream();
return _previousStream = new BoundarySubStream(this);
}
@@ -91,18 +89,20 @@ public string ReadLine()
public string ReadLine(out bool crlfFound)
{
- TerminateExistingStream(true);
+ TerminateExistingStream();
if (AtEndBoundary)
{
crlfFound = true;
return null;
}
- byte[] toConvert = ReadUntil(crLf, true, out crlfFound);
+
+ var toConvert = ReadUntil(_newLine, true, out crlfFound);
if (toConvert == null)
{
AtEndBoundary = true; // reached the end of the steam
return null;
}
+
string convertedLine = toConvert.Length == 0 ? string.Empty : Encoding.GetString(toConvert).TrimEnd();
if (string.Compare(convertedLine, _beginBoundaryAsString, StringComparison.OrdinalIgnoreCase) == 0)
{
@@ -110,13 +110,15 @@ public string ReadLine(out bool crlfFound)
AtBoundary = true;
return convertedLine;
}
- else if (string.Compare(convertedLine, _beginBoundaryAsString + "--", StringComparison.OrdinalIgnoreCase) == 0)
+
+ if (string.Compare(convertedLine, _beginBoundaryAsString + "--", StringComparison.OrdinalIgnoreCase) == 0)
{
AtPreamble = false;
AtBoundary = true;
AtEndBoundary = true;
return convertedLine;
}
+
return convertedLine;
}
@@ -127,7 +129,7 @@ public byte[] ReadNextPart()
var part = new MemoryStream();
long count = ReadNextPart(part, true);
var result = new byte[count];
- Buffer.BlockCopy(part.GetBuffer(), 0, result, 0, (int) count);
+ Buffer.BlockCopy(part.GetBuffer(), 0, result, 0, (int)count);
return result;
}
@@ -135,46 +137,44 @@ public long ReadNextPart(Stream destinationStream, bool continueToNextBoundaryOn
{
if (AtEndBoundary)
return 0;
- TerminateExistingStream(true);
+ TerminateExistingStream();
if (AtEndBoundary)
return 0;
long bytesRead = 0;
- long lastRead = 0;
+ long lastRead;
+ if (TryReadPreamble(destinationStream, ref bytesRead))
+ return bytesRead;
+
bool markerFound;
+ while ((lastRead = ReadUntil(destinationStream, _beginBoundary, false, out markerFound)) >= 0)
{
- if (TryReadPreamble(destinationStream, ref bytesRead))
- return bytesRead;
-
- while ((lastRead = ReadUntil(destinationStream, _beginBoundary, false, out markerFound)) >= 0)
+ bytesRead += lastRead;
+ if (markerFound)
{
- bool lastReadWasPreamble = AtPreamble;
- bytesRead += lastRead;
- if (markerFound)
- {
- BaseStream.Read(new byte[2], 0, 2);
+ BaseStream.Read(new byte[2], 0, 2);
- string line = ReadLine();
+ string line = ReadLine();
- if (AtBoundary || AtEndBoundary)
- {
- if (bytesRead == 0 && continueToNextBoundaryOnEmptyRead) // no data between boundaries
- continue;
- break;
- }
- destinationStream.Write(crLf, 0, 2);
- byte[] encodedLine = Encoding.GetBytes(line);
- destinationStream.Write(encodedLine, 0, encodedLine.Length);
- destinationStream.Write(crLf, 0, 2);
- bytesRead += encodedLine.Length + 4;
- }
- else
+ if (AtBoundary || AtEndBoundary)
{
+ if (bytesRead == 0 && continueToNextBoundaryOnEmptyRead) // no data between boundaries
+ continue;
break;
}
- }
- return bytesRead;
+ destinationStream.Write(_newLine, 0, 2);
+ var encodedLine = Encoding.GetBytes(line);
+ destinationStream.Write(encodedLine, 0, encodedLine.Length);
+ destinationStream.Write(_newLine, 0, 2);
+ bytesRead += encodedLine.Length + 4;
+ }
+ else
+ {
+ break;
+ }
}
+
+ return bytesRead;
}
public long SeekToNextPart()
@@ -187,6 +187,7 @@ public long SeekToNextPart()
SkipPreamble();
return 0;
}
+
return ReadNextPart(Stream.Null, false);
}
@@ -197,10 +198,9 @@ byte[] ReadUntil(byte[] marker, bool swallowMarker, out bool markerFound)
long count = ReadUntil(dataToSendBack, marker, swallowMarker, out markerFound);
if (count == 0 && markerFound)
return new byte[0];
- else if (count == 0 && !markerFound)
+ if (count == 0 && !markerFound)
return null;
- else
- return dataToSendBack.ToArray();
+ return dataToSendBack.ToArray();
}
int ReadUntil(byte[] buffer, int offset, int count, byte[] marker, out MatchState lastMatch)
@@ -212,32 +212,33 @@ int ReadUntil(byte[] buffer, int offset, int count, byte[] marker, out MatchStat
int lastReadCount = BaseStream.Read(_localBuffer, _localBufferLength, maxReadLength);
if (lastReadCount > 0)
{
- MatchResult searchResult = _localBuffer.Match(0L, marker, 0, lastReadCount + _localBufferLength);
+ var searchResult = _localBuffer.Match(0L, marker, 0, lastReadCount + _localBufferLength);
lastMatch = searchResult.State;
if (searchResult.State == MatchState.Found)
{
if (searchResult.Index > 0)
- Buffer.BlockCopy(_localBuffer, 0, buffer, offset, (int) searchResult.Index);
+ Buffer.BlockCopy(_localBuffer, 0, buffer, offset, (int)searchResult.Index);
long leftOver = (_localBufferLength + lastReadCount) - searchResult.Index;
- BaseStream.Seek(leftOver*-1, SeekOrigin.Current);
+ BaseStream.Seek(leftOver * -1, SeekOrigin.Current);
_localBufferLength = 0;
- totalRead = (int) searchResult.Index;
+ totalRead = (int)searchResult.Index;
}
else if (searchResult.State == MatchState.NotFound)
{
- Buffer.BlockCopy(_localBuffer, 0, buffer, offset, lastReadCount + _localBufferLength);
- totalRead = lastReadCount;
+ totalRead = lastReadCount + _localBufferLength;
+ Buffer.BlockCopy(_localBuffer, 0, buffer, offset, totalRead);
+
_localBufferLength = 0;
}
else if (searchResult.State == MatchState.Truncated)
{
- totalRead = (int) searchResult.Index;
+ totalRead = (int)searchResult.Index;
Buffer.BlockCopy(_localBuffer, 0, buffer, offset, totalRead);
int datalength = lastReadCount + _localBufferLength;
- int leftover = datalength - (int) searchResult.Index;
- Buffer.BlockCopy(_localBuffer, (int) searchResult.Index, _localBuffer, 0, leftover);
+ int leftover = datalength - (int)searchResult.Index;
+ Buffer.BlockCopy(_localBuffer, (int)searchResult.Index, _localBuffer, 0, leftover);
_localBufferLength = leftover;
}
}
@@ -247,6 +248,7 @@ int ReadUntil(byte[] buffer, int offset, int count, byte[] marker, out MatchStat
totalRead = _localBufferLength;
_localBufferLength = 0;
}
+
return totalRead;
}
@@ -257,7 +259,7 @@ long ReadUntil(Stream destinationStream, byte[] marker, bool swallowMarker, out
markerFound = false;
AtBoundary = false;
AtEndBoundary = false;
- int lastReadCount = 0;
+ int lastReadCount;
long totalCount = 0;
MatchState lastState;
@@ -266,12 +268,14 @@ long ReadUntil(Stream destinationStream, byte[] marker, bool swallowMarker, out
destinationStream.Write(buffer, 0, lastReadCount);
totalCount += lastReadCount;
}
+
if (lastState == MatchState.Found)
{
markerFound = true;
if (swallowMarker)
BaseStream.Seek(marker.Length, SeekOrigin.Current);
}
+
return totalCount;
}
@@ -285,16 +289,15 @@ void SkipPreamble()
Log.WriteDebug("Preamble found: {0} of size {1}", preambleRead, preambleSize);
}
- void TerminateExistingStream(bool seekToNextPart)
+ void TerminateExistingStream()
{
Log.WriteDebug("TerminateExistingStream(), previous stream was " + _previousStream == null ? "null" : "not null");
if (_previousStream != null)
{
- _previousStream.atEnd = true;
+ _previousStream.AtEnd = true;
_previousStream = null;
SeekToNextPart();
}
-
}
bool TryReadPreamble(Stream destinationStream, ref long bytesRead)
@@ -316,29 +319,32 @@ bool TryReadPreamble(Stream destinationStream, ref long bytesRead)
{
if (preambleRead)
{
- destinationStream.Write(crLf);
+ destinationStream.Write(_newLine);
bytesRead += 2;
}
- byte[] encodedLine = Encoding.GetBytes(currentLine);
+
+ var encodedLine = Encoding.GetBytes(currentLine);
destinationStream.Write(encodedLine);
bytesRead += encodedLine.Length;
}
+
preambleRead = true;
}
else
lastPreambleCrLfPending = false;
}
+
if (wasAtPreamble && lastPreambleCrLfPending && bytesRead > 0)
{
- destinationStream.Write(crLf);
+ destinationStream.Write(_newLine);
bytesRead += 2;
}
+
return wasAtPreamble;
}
class BoundarySubStream : Stream
{
- public bool atEnd;
readonly BoundaryStreamReader _reader;
public BoundarySubStream(BoundaryStreamReader reader)
@@ -346,6 +352,8 @@ public BoundarySubStream(BoundaryStreamReader reader)
_reader = reader;
}
+ public bool AtEnd { get; set; }
+
public override bool CanRead
{
get { return true; }
@@ -381,12 +389,12 @@ public override void Flush()
public override int Read(byte[] buffer, int offset, int count)
{
- if (atEnd)
+ if (AtEnd)
return 0;
MatchState state;
int resultCount = _reader.ReadUntil(buffer, offset, count, _reader._beginBoundary, out state);
if (state == MatchState.Found) // reached a boundary
- atEnd = true;
+ AtEnd = true;
return resultCount;
}
@@ -410,7 +418,6 @@ public override void Write(byte[] buffer, int offset, int count)
}
#region Full license
-
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
@@ -427,5 +434,4 @@ public override void Write(byte[] buffer, int offset, int count)
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
#endregion
17 src/core/OpenRasta/IO/StreamExtensions.cs
View
@@ -1,5 +1,4 @@
#region License
-
/* Authors:
* Sebastien Lambla (seb@serialseb.com)
* Copyright:
@@ -16,14 +15,18 @@ namespace OpenRasta.IO
{
public static class StreamExtensions
{
- public static void CopyTo(this Stream stream, Stream destinationStream)
+ public static long CopyTo(this Stream stream, Stream destinationStream)
{
var buffer = new byte[4096];
int readCount = 0;
+ long totalWritten = 0;
while ((readCount = stream.Read(buffer, 0, buffer.Length)) > 0)
{
+ totalWritten += readCount;
destinationStream.Write(buffer, 0, readCount);
}
+
+ return totalWritten;
}
public static byte[] ReadToEnd(this Stream stream)
@@ -35,9 +38,13 @@ public static byte[] ReadToEnd(this Stream stream)
stream.CopyTo(streamToReturn);
streamToReturn.Position = 0;
}
+
var destinationBytes = new byte[streamToReturn.Length - streamToReturn.Position];
- Buffer.BlockCopy(streamToReturn.GetBuffer(), (int) streamToReturn.Position, destinationBytes, 0,
- (int) (streamToReturn.Length - streamToReturn.Position));
+ Buffer.BlockCopy(streamToReturn.GetBuffer(),
+ (int)streamToReturn.Position,
+ destinationBytes,
+ 0,
+ (int)(streamToReturn.Length - streamToReturn.Position));
return destinationBytes;
}
@@ -49,7 +56,6 @@ public static void Write(this Stream stream, byte[] buffer)
}
#region Full license
-
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
@@ -66,5 +72,4 @@ public static void Write(this Stream stream, byte[] buffer)
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
#endregion
7 src/core/OpenRasta/OpenRasta.csproj
View
@@ -23,7 +23,7 @@
<TargetFrameworkSubset>
</TargetFrameworkSubset>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v3.5</TargetFrameworkVersion>
- <RuntimeTargetFrameworkVersion>$(TargetFrameworkVersion)</RuntimeTargetFrameworkVersion>
+ <RuntimeTargetFrameworkVersion Condition="'$(RuntimeTargetFrameworkVersion)' == ''">$(TargetFrameworkVersion)</RuntimeTargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -32,7 +32,6 @@
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
- <RuntimeTargetFrameworkVersion>v3.5</RuntimeTargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -121,7 +120,7 @@
<Compile Include="Diagnostics\LogSource.cs" />
<Compile Include="Diagnostics\NullErrorCollector.cs" />
<Compile Include="Diagnostics\OperationContextErrorCollector.cs" />
- <Compile Include="Diagnostics\PipelineLogSource.cs" />
+ <Compile Include="Pipeline\Diagnostics\PipelineLogSource.cs" />
<Compile Include="DI\Internal\ContextStoreDependency.cs" />
<Compile Include="DI\Internal\ContextStoreExtensions.cs" />
<Compile Include="Error.cs" />
@@ -297,6 +296,7 @@
<Compile Include="Web\Handlers\HttpMethodNameHandlerMethodSelector.cs" />
<Compile Include="Web\HttpEntityFile.cs" />
<Compile Include="Web\IHttpMessage.cs" />
+ <Compile Include="Web\Internal\CommunicationContextExtensions.cs" />
<Compile Include="Web\ISupportsTextWriter.cs" />
<Compile Include="Web\IUriTemplateParser.cs" />
<Compile Include="Web\Markup\Attributes\Annotations\CharsetAttribute.cs" />
@@ -470,6 +470,7 @@
<Compile Include="Pipeline\Contributors\ResponseEntityCodecResolverContributor.cs" />
<Compile Include="Pipeline\PipelineStage.cs" />
<Compile Include="Web\ServerErrorList.cs" />
+ <Compile Include="Web\TemplatedUriResolverLegacyExtensions.cs" />
<Compile Include="Web\UriDecorators\HttpMethodOverrideUriDecorator.cs" />
<Compile Include="Web\UriDecorators\PathSegmentAsParameterUriDecorator.cs" />
<Compile Include="Web\UriDecorators\ContentTypeExtensionUriDecorator.cs" />
6 src/core/OpenRasta/OperationModel/Filters/HttpMethodOperationFilter.cs
View
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using OpenRasta.Diagnostics;
using OpenRasta.Web;
@@ -10,7 +9,6 @@ namespace OpenRasta.OperationModel.Filters
public class HttpMethodOperationFilter : IOperationFilter
{
readonly IRequest _request;
- public ILogger Log { get; set; }
public HttpMethodOperationFilter(IRequest request)
{
@@ -18,12 +16,14 @@ public HttpMethodOperationFilter(IRequest request)
Log = NullLogger.Instance;
}
+ public ILogger Log { get; set; }
+
public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
{
operations = operations.ToList();
var operationWithMatchingName = OperationsWithMatchingName(operations);
var operationWithMatchingAttribute = OperationsWithMatchingAttribute(operations);
- Log.WriteDebug("Found {0} operation(s) with a matching name.",operationWithMatchingName.Count());
+ Log.WriteDebug("Found {0} operation(s) with a matching name.", operationWithMatchingName.Count());
Log.WriteDebug("Found {0} operation(s) with matching [HttpOperation] attribute.", operationWithMatchingAttribute.Count());
return operationWithMatchingName.Union(operationWithMatchingAttribute);
}
7 src/core/OpenRasta/OperationModel/Filters/UriNameOperationFilter.cs
View
@@ -9,7 +9,6 @@ namespace OpenRasta.OperationModel.Filters
public class UriNameOperationFilter : IOperationFilter
{
readonly ICommunicationContext _commContext;
- public ILogger<OperationModelLogSource> Log { get; set; }
public UriNameOperationFilter(ICommunicationContext commContext)
{
@@ -17,6 +16,8 @@ public UriNameOperationFilter(ICommunicationContext commContext)
Log = NullLogger<OperationModelLogSource>.Instance;
}
+ public ILogger<OperationModelLogSource> Log { get; set; }
+
public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
{
if (_commContext.PipelineData.SelectedResource == null
@@ -26,13 +27,11 @@ public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
return operations;
}
- List<IOperation> attribOperations = OperationsWithMatchingAttribute(operations).ToList();
+ var attribOperations = OperationsWithMatchingAttribute(operations).ToList();
Log.FoundOperations(attribOperations);
return attribOperations.Count > 0 ? attribOperations : operations;
}
-
-
IEnumerable<IOperation> OperationsWithMatchingAttribute(IEnumerable<IOperation> operations)
{
return from operation in operations
41 src/core/OpenRasta/OperationModel/Filters/UriParametersFilter.cs
View
@@ -1,15 +1,14 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
-using System.Diagnostics;
using System.Linq;
using System.Text;
using OpenRasta.Binding;
using OpenRasta.Collections;
using OpenRasta.Diagnostics;
+using OpenRasta.Pipeline;
using OpenRasta.TypeSystem.ReflectionBased;
using OpenRasta.Web;
-using OpenRasta.Pipeline;
namespace OpenRasta.OperationModel.Filters
{
@@ -29,7 +28,6 @@ public UriParametersFilter(ICommunicationContext context, IErrorCollector collec
public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
{
-
int acceptedMethods = 0;
foreach (var operation in operations)
@@ -37,6 +35,7 @@ public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
if (IsEmpty(_pipelineData.SelectedResource.UriTemplateParameters))
{
LogAcceptNoUriParameters(operation);
+ acceptedMethods++;
yield return operation;
continue;
}
@@ -45,14 +44,10 @@ public IEnumerable<IOperation> Process(IEnumerable<IOperation> operations)
{
var uriParametersCopy = new NameValueCollection(uriParameterMatches);
- IEnumerable<string> matchedParameters = from member in operation.Inputs
- from matchedParameterName in uriParametersCopy.AllKeys
- let success = member.Binder.SetProperty(
- matchedParameterName,
- uriParametersCopy.GetValues(matchedParameterName),
- ConvertFromString)
- where success
- select matchedParameterName;
+ var matchedParameters = from member in operation.Inputs
+ from matchedParameterName in uriParametersCopy.AllKeys
+ where TrySetPropertyAndRemoveUsedKey(member, matchedParameterName, uriParametersCopy, ConvertFromString)
+ select matchedParameterName;
if (matchedParameters.Count() == uriParameterMatches.Count)
{
@@ -62,6 +57,7 @@ where success
}
}
}
+
LogAcceptedCount(acceptedMethods);
if (acceptedMethods <= 0)
@@ -74,7 +70,7 @@ static BindingResult ConvertFromString(string strings, Type entityType)
{
return BindingResult.Success(entityType.CreateInstanceFrom(strings));
}
- catch(Exception e)
+ catch (Exception e)
{
if (e.InnerException is FormatException)
return BindingResult.Failure();
@@ -86,9 +82,9 @@ static ErrorFrom<UriParametersFilter> CreateErrorNoOperationFound(IEnumerable<Na
{
return new ErrorFrom<UriParametersFilter>
{
- Title = "No method matched the uri parameters",
+ Title = "No method matched the uri parameters",
Message = string.Format(
- "None of the operations had members that could be matches against the uri parameters:\r\n{0}",
+ "None of the operations had members that could be matches against the uri parameters:\r\n{0}",
FormatUriParameterMatches(uriTemplateParameters))
};
}
@@ -119,10 +115,21 @@ void LogAcceptNoUriParameters(IOperation operation)
void LogOperationAccepted(NameValueCollection uriParameterMatches, IOperation operation)
{
Logger.WriteDebug(
- "Accepted operation {0} with {1} matched parameters for uri parameter list {2}.",
- operation.Name,
- operation.Inputs.CountReady(),
+ "Accepted operation {0} with {1} matched parameters for uri parameter list {2}.",
+ operation.Name,
+ operation.Inputs.CountReady(),
uriParameterMatches.ToHtmlFormEncoding());
}
+
+ bool TrySetPropertyAndRemoveUsedKey(InputMember member, string uriParameterName, NameValueCollection uriParameters, ValueConverter<string> converter)
+ {
+ if (member.Binder.SetProperty(uriParameterName, uriParameters.GetValues(uriParameterName), converter))
+ {
+ uriParameters.Remove(uriParameterName);
+ return true;
+ }
+
+ return false;
+ }
}
}
16 src/core/OpenRasta/Pipeline/Contributors/DigestAuthorizerContributor.cs
View
@@ -58,10 +58,8 @@ public PipelineContinuation ReadCredentials(ICommunicationContext context)
_authentication = _resolver.Resolve<IAuthenticationProvider>();
- string header = context.Request.Headers["Authorization"];
- if (string.IsNullOrEmpty(header))
- return PipelineContinuation.Continue;
- DigestHeader authorizeHeader = DigestHeader.Parse(header);
+ DigestHeader authorizeHeader = GetDigestHeader(context);
+
if (authorizeHeader == null)
return PipelineContinuation.Continue;
@@ -79,7 +77,6 @@ public PipelineContinuation ReadCredentials(ICommunicationContext context)
Password = creds.Password,
Uri = authorizeHeader.Uri
};
-
string hashedDigest = checkHeader.GetCalculatedResponse(context.Request.HttpMethod);
if (authorizeHeader.Response == hashedDigest)
@@ -91,6 +88,15 @@ public PipelineContinuation ReadCredentials(ICommunicationContext context)
return NotAuthorized(context);
}
+ static DigestHeader GetDigestHeader(ICommunicationContext context)
+ {
+ string header = context.Request.Headers["Authorization"];
+ return string.IsNullOrEmpty(header) ? null : DigestHeader.Parse(header);
+ }
+ static bool HasDigestHeader(ICommunicationContext context)
+ {
+ return GetDigestHeader(context) != null;
+ }
static PipelineContinuation ClientError(ICommunicationContext context)
{
context.OperationResult = new OperationResult.BadRequest();
1  src/core/OpenRasta/Pipeline/Contributors/OperationCreatorContributor.cs
View
@@ -2,6 +2,7 @@
using System.Linq;
using OpenRasta.Diagnostics;
using OpenRasta.OperationModel;
+using OpenRasta.Pipeline.Diagnostics;
using OpenRasta.Web;
using OpenRasta.Pipeline;
6 src/core/OpenRasta/Pipeline/Contributors/ResourceTypeResolverContributor.cs
View
@@ -13,6 +13,7 @@
using OpenRasta.Diagnostics;
using OpenRasta.Web;
using OpenRasta.Pipeline;
+using OpenRasta.Web.Internal;
namespace OpenRasta.Pipeline.Contributors
{
@@ -37,10 +38,7 @@ PipelineContinuation ResolveResource(ICommunicationContext context)
{
if (context.PipelineData.SelectedResource == null)
{
- var uriToMath = context.ApplicationBaseUri
- .EnsureHasTrailingSlash()
- .MakeRelativeUri(context.Request.Uri)
- .MakeAbsolute("http://localhost");
+ var uriToMath = context.GetRequestUriRelativeToRoot();
var uriMatch = _uriRepository.Match(uriToMath);
if (uriMatch != null)
{
4 src/core/OpenRasta/Diagnostics/PipelineLogSource.cs → ...enRasta/Pipeline/Diagnostics/PipelineLogSource.cs
View
@@ -1,4 +1,6 @@
-namespace OpenRasta.Diagnostics
+using OpenRasta.Diagnostics;
+
+namespace OpenRasta.Pipeline.Diagnostics
{
[LogCategory("openrasta.pipeline")]
public class PipelineLogSource : ILogSource
90 src/core/OpenRasta/Pipeline/PipelineRunner.cs
View
@@ -15,6 +15,7 @@
using OpenRasta.Collections.Specialized;
using OpenRasta.DI;
using OpenRasta.Diagnostics;
+using OpenRasta.Pipeline.Diagnostics;
using OpenRasta.Web;
namespace OpenRasta.Pipeline
@@ -33,11 +34,14 @@ public PipelineRunner(IDependencyResolver resolver)
Contributors = new ReadOnlyCollection<IPipelineContributor>(_contributors);
_resolver = resolver;
+ PipelineLog = NullLogger<PipelineLogSource>.Instance;
+ Log = NullLogger.Instance;
}
public IList<IPipelineContributor> Contributors { get; private set; }
public bool IsInitialized { get; private set; }
+ public ILogger<PipelineLogSource> PipelineLog { get; set; }
public ILogger Log { get; set; }
IEnumerable<ContributorCall> IPipeline.CallGraph
@@ -53,24 +57,24 @@ public void Initialize()
{
if (IsInitialized)
return;
- using (Log.Operation(this, "Initializing the pipeline."))
+ using (PipelineLog.Operation(this, "Initializing the pipeline."))
{
foreach (var item in _resolver.ResolveAll<IPipelineContributor>())
{
- Log.WriteDebug("Initialized contributor {0}.", item.GetType());
+ PipelineLog.WriteDebug("Initialized contributor {0}.", item.GetType().Name);
_contributors.Add(item);
}
_callGraph = GenerateCallGraph();
}
IsInitialized = true;
- Log.WriteInfo("Pipeline has been successfully initialized.");
+ PipelineLog.WriteInfo("Pipeline has been successfully initialized.");
}
public IPipelineExecutionOrder Notify(Func<ICommunicationContext, PipelineContinuation> action)
{
if (IsInitialized)
{
- Log.WriteWarning("A pipeline registration through Notify() has been done after the pipeline was initialized. Ignoring.");
+ PipelineLog.WriteWarning("A pipeline registration through Notify() has been done after the pipeline was initialized. Ignoring.");
return new Notification(this,action);
}
var notification = new Notification(this, action);
@@ -118,10 +122,10 @@ void RunCallGraph(ICommunicationContext context, PipelineStage stage)
}
void RenderNow(ICommunicationContext context, PipelineStage stage)
{
- Log.WriteDebug("Pipeline is in RenderNow mode.");
+ PipelineLog.WriteDebug("Pipeline is in RenderNow mode.");
if (!stage.ResumeFrom<KnownStages.IOperationResultInvocation>())
{
- using (Log.Operation(this, "Rendering contributor has already been executed. Calling a nested pipeline to render the error."))
+ using (PipelineLog.Operation(this, "Rendering contributor has already been executed. Calling a nested pipeline to render the error."))
{
var nestedPipeline = new PipelineStage(this);
if (!nestedPipeline.ResumeFrom<KnownStages.IOperationResultInvocation>())
@@ -130,64 +134,12 @@ void RenderNow(ICommunicationContext context, PipelineStage stage)
}
}
}
- //void RunCallGraph(ICommunicationContext context, bool renderNow)
- //{
- // bool renderStageExecuted = false;
- // bool ignoreUntilRenderer = renderNow;
-
- // foreach (var call in _callGraph)
- // {
- // if (!CanBeExecuted(call))
- // continue;
-
- // if (call.Target == _renderStage)
- // renderStageExecuted = true;
- // if (ignoreUntilRenderer)
- // {
- // if (call.Target != _renderStage)
- // {
- // Log.WriteDebug("Waiting for renderer contributor. Ignoring {0}.", call.ContributorTypeName);
- // continue;
- // }
- // ignoreUntilRenderer = false;
- // }
- // PipelineContinuation nextStep;
- // using (
- // Log.Operation(this,
- // "Executing contributor {0}.{1}".With(call.ContributorTypeName, call.Action.Method.Name))
- // )
- // {
- // nextStep = ExecuteContributor(context, call);
- // }
- // if (nextStep == PipelineContinuation.Abort)
- // {
- // AbortPipeline(context);
- // nextStep = PipelineContinuation.RenderNow;
- // }
- // if (nextStep == PipelineContinuation.Finished)
- // FinishPipeline(context);
- // if (nextStep == PipelineContinuation.RenderNow)
- // {
- // Log.WriteDebug("Pipeline is in RenderNow mode.");
- // if (renderStageExecuted && !renderNow)
- // {
- // using (
- // Log.Operation(this,
- // "Rendering contributor has already been executed. Calling a nested pipeline to render the error.")
- // )
- // RunCallGraph(context, true);
- // return;
- // }
- // ignoreUntilRenderer = true;
- // }
- // }
- //}
bool CanBeExecuted(ContributorCall call)
{
if (call.Action == null)
{
- Log.WriteWarning("Contributor call for {0} had a null Action.", call.ContributorTypeName);
+ PipelineLog.WriteWarning("Contributor call for {0} had a null Action.", call.ContributorTypeName);
return false;
}
return true;
@@ -195,7 +147,7 @@ bool CanBeExecuted(ContributorCall call)
protected virtual void AbortPipeline(ICommunicationContext context)
{
- Log.WriteError("Aborting the pipeline and rendering the errors.");
+ PipelineLog.WriteError("Aborting the pipeline and rendering the errors.");
context.OperationResult = new OperationResult.InternalServerError
{
Title =
@@ -206,11 +158,13 @@ protected virtual void AbortPipeline(ICommunicationContext context)
context.Response.Entity.Instance = context.ServerErrors;
context.Response.Entity.Codec = null;
context.Response.Entity.ContentLength = null;
+
+ Log.WriteError("An error has occurred and the processing of the request has stopped.\r\n{0}", context.ServerErrors.Aggregate(string.Empty, (str, error) => str + "\r\n" + error.ToString()));
}
protected virtual PipelineContinuation ExecuteContributor(ICommunicationContext context, ContributorCall call)
{
- using (Log.Operation(this, "Executing contributor {0}.{1}".With(call.ContributorTypeName, call.Action.Method.Name)))
+ using (PipelineLog.Operation(this, "Executing contributor {0}.{1}".With(call.ContributorTypeName, call.Action.Method.Name)))
{
PipelineContinuation nextStep;
try
@@ -219,11 +173,11 @@ protected virtual PipelineContinuation ExecuteContributor(ICommunicationContext
}
catch (Exception e)
{
- Log.WriteException(e);
context.ServerErrors.Add(new Error
{
- Title = "An exception was thrown while processing a pipeline contributor",
- Message = e.ToString()
+ Title = "Fatal error",
+ Message = "An exception was thrown while processing a pipeline contributor",
+ Exception = e
});
nextStep = PipelineContinuation.Abort;
}
@@ -233,7 +187,7 @@ protected virtual PipelineContinuation ExecuteContributor(ICommunicationContext
protected virtual void FinishPipeline(ICommunicationContext context)
{
- Log.WriteInfo("Pipeline finished.");
+ PipelineLog.WriteInfo("Pipeline finished.");
}
@@ -246,7 +200,7 @@ IEnumerable<ContributorCall> GenerateCallGraph()
foreach (var contrib in _contributors.Where(x=>x != bootstrapper))
{