Skip to content

Commit

Permalink
ChainExecutionLog.ReadHeaders(http)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Aug 25, 2015
1 parent 92c7a7d commit 9795db8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using FubuCore.Logging;
using FubuMVC.Core.Http.Owin;
using FubuMVC.Core.Registration.Nodes;

namespace FubuMVC.Core.Diagnostics.Instrumentation
Expand Down Expand Up @@ -115,12 +116,12 @@ public void Trace(string description, Action action)

public void RecordHeaders(IDictionary<string, object> env)
{
throw new NotImplementedException();
env.CopyTo(_request, "owin.RequestHeaders", "owin.RequestMethod", "owin.RequestPath", "owin.RequestPathBase", "owin.RequestProtocol", "owin.RequestQueryString", "owin.RequestScheme", "owin.ResponseHeaders", "owin.ResponseStatusCode", "owin.ResponseReasonPhrase");
}

public void RecordBody(IDictionary<string, object> env)
{
throw new NotImplementedException();
// TODO -- will need to get the request body somehow
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using FubuCore.Logging;
using FubuMVC.Core.Diagnostics.Instrumentation;
using FubuMVC.Core.Http.Owin;
using NUnit.Framework;
using Rhino.Mocks;
using Shouldly;
Expand Down Expand Up @@ -150,6 +151,37 @@ public void mark_finished()

log.Request["A"].ShouldBe(1);
}

[Test]
public void record_headers_from_http_request()
{
var dict = new Dictionary<string, object>();
dict.Add("owin.RequestHeaders", 1);
dict.Add("owin.RequestMethod", 2);
dict.Add("owin.RequestPath", 3);
dict.Add("owin.RequestPathBase", 4);
dict.Add("owin.RequestProtocol", 5);
dict.Add("owin.RequestQueryString", 6);
dict.Add("owin.RequestScheme", 7);
dict.Add("owin.ResponseHeaders", 8);
dict.Add("owin.ResponseStatusCode", 9);
dict.Add("owin.ResponseReasonPhrase", 10);

var log = new ChainExecutionLog();

log.RecordHeaders(dict);

log.Request["owin.RequestHeaders"].ShouldBe(1);
log.Request["owin.RequestMethod"].ShouldBe(2);
log.Request["owin.RequestPath"].ShouldBe(3);
log.Request["owin.RequestPathBase"].ShouldBe(4);
log.Request["owin.RequestProtocol"].ShouldBe(5);
log.Request["owin.RequestQueryString"].ShouldBe(6);
log.Request["owin.RequestScheme"].ShouldBe(7);
log.Request["owin.ResponseHeaders"].ShouldBe(8);
log.Request["owin.ResponseStatusCode"].ShouldBe(9);
log.Request["owin.ResponseReasonPhrase"].ShouldBe(10);
}
}

public class StubbedChainExecutionLog : ChainExecutionLog
Expand Down
1 change: 0 additions & 1 deletion src/FubuMVC.Tests/Http/Owin/DictionaryExtensionsTester.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Security.Cryptography;
using FubuMVC.Core.Http.Owin;
using NUnit.Framework;
using Shouldly;
Expand Down

0 comments on commit 9795db8

Please sign in to comment.