-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Replace HttpBin.org/response-headers Tests with WebListener #5058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TravisEz13
merged 5 commits into
PowerShell:master
from
markekraus:ReplaceHttpBinResponseHeaders
Oct 18, 2017
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
45d79d1
Replace HttpBin.org/response-headers Tests with WebListener
markekraus af251d1
[Feature] Run Feature tests
markekraus 1ec53e5
[Feature] Add Spelling Override
markekraus 3bb96a2
Address PR feedback
markekraus 8f900ec
[Feature] Re-run CI
markekraus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/tools/WebListener/Controllers/ResponseHeadersController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| using System; | ||
| using System.Collections; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.AspNetCore.Http.Extensions; | ||
| using Microsoft.Extensions.Primitives; | ||
| using Newtonsoft.Json; | ||
| using mvc.Models; | ||
|
|
||
| namespace mvc.Controllers | ||
| { | ||
| public class ResponseHeadersController : Controller | ||
| { | ||
| public string Index() | ||
| { | ||
| Hashtable headers = new Hashtable(); | ||
| foreach (var key in Request.Query.Keys) | ||
| { | ||
| headers.Add(key, String.Join(Constants.HeaderSeparator, Request.Query[key])); | ||
|
|
||
| if (String.Equals("Content-Type", key, StringComparison.InvariantCultureIgnoreCase)) | ||
| { | ||
| // Content-Type must be applied right before it is sent to the client or MVC will overwrite. | ||
| string contentType = Request.Query[key]; | ||
| Response.OnStarting(state => | ||
| { | ||
| var httpContext = (HttpContext) state; | ||
| httpContext.Response.ContentType = contentType; | ||
| return Task.FromResult(0); | ||
| }, HttpContext); | ||
| } | ||
| else | ||
| { | ||
| Response.Headers.TryAdd(key, Request.Query[key]); | ||
| } | ||
| } | ||
| return JsonConvert.SerializeObject(headers); | ||
| } | ||
|
|
||
| public IActionResult Error() | ||
| { | ||
| return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are they really all used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you are asking. But, I added a file level override because I had been putting all of the overrides for this in the Global dictionary. That was probably a poor decision, so I'm adding the new section and will do a separate PR after this is merged to move the ones from my previous PRs from global to the file override.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Clear.
Closed.