Skip to content

Conversation

@markekraus
Copy link
Contributor

PR Summary

reference #5464
closes #4639

  • Add Link controller to WebListener
  • Replace HttpListener Link tests with WebListener
  • Update WebListener Documentation
  • Enable cross-platform multiple Link header tests

PR Checklist

Note: Please mark anything not applicable to this PR NA.

@markekraus
Copy link
Contributor Author

Let it be known that on this day of January 6th, 2018 the macOS CI build finished before Linux and Windows...

@bergmeister
Copy link
Contributor

@markekraus Maybe because macOS hasn't patched the Spectre bug yet, you can thank Intel for that 😛 (just kidding)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, one of the last .Net Core SDK updates included the latest version of Roslyn, therefore it should be possible to inline the out parameter declarations as e.g. out StringValues maxLinksSV, etc.
Very minor but here and below is no space after the if statement (tip: just select everything and Ctrl+K+F auto-formats you all those things)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really a C# developer... so that inline trick is new to me. Good to know! I've changed all the instances of it.

For some reason.. the keyboard shortcuts for formatting are not working for me *scratches head. I had to right-click and chose format document. weird. Any way, formatting is fixed now.

Copy link
Contributor

@bergmeister bergmeister Jan 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, C# is moving quite fast now and it is hard to keep up, you can have a read here or watch one of the videos from Kasey Uhlenhuth if you are interested but I mainly learn those tricks also from other people when pair programming or reviewing. Here are my personal favourites :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing me in the right direction. Discards will come in handy too.

@daxian-dbw daxian-dbw self-assigned this Jan 8, 2018
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be any links in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never mind

$result.Output.RelationLink["next"] | Should BeExactly "http://localhost:8080/PowerShell?test=linkheader&maxlinks=5&linknumber=2"
$result.Output.RelationLink["last"] | Should BeExactly "http://localhost:8080/PowerShell?test=linkheader&maxlinks=5&linknumber=5"

$result.Output.RelationLink.Count | Should BeExactly 5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we use BeExactly in the whole file for Count?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was like that before I didn't change them. Does it really matter though?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer Should Be because BeExactly is used for strings and my first thought was that here Count is a method in RelationLink which return a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iSazonov This appears to happen in more place. Lets leave it as is here and I will address them all as part of #5669 which I have updated.

linkNumber = 1;
}

string baseUri = Regex.Replace(UriHelper.GetDisplayUrl(Request), "\\?.*", String.Empty);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So simple? 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something wrong with it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I expected a url parsing 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh. So far as I can tell, the only way to get the request url is GetDisplayUrl() which returns a string. I could use UriBuilder on that string.. BUT.. on macOS UriBuilder behaves differently with the query section resulting in invalid urls.. rather than mess with that, the regex works just fine :)

var getController = new GetController();
getController.ControllerContext = this.ControllerContext;
var result = getController.Index();
var output = result.Value as Hashtable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will always return a HashTable unless some uncaught exception prevents it from even getting to this point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Closed.

@markekraus
Copy link
Contributor Author

@daxian-dbw ping

@daxian-dbw daxian-dbw merged commit 3f9564e into PowerShell:master Jan 16, 2018
@markekraus markekraus deleted the ReplaceHttpListernerLink branch January 19, 2018 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for multiple response headers with the same name from HttpListener

5 participants