Skip to content
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

[Uri] Add UriScheme Properties: SSH, FTPS, SFTP, WS, WSS #35180

Closed
ArthurHNL opened this issue Apr 19, 2020 · 12 comments
Closed

[Uri] Add UriScheme Properties: SSH, FTPS, SFTP, WS, WSS #35180

ArthurHNL opened this issue Apr 19, 2020 · 12 comments
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Net
Milestone

Comments

@ArthurHNL
Copy link

ArthurHNL commented Apr 19, 2020

Currently, the System.Uri class has static fields for the Scheme part of a URI of common protocols:

  • UriSchemeFile
  • UriSchemeFtp
  • UriSchemeGopher
  • UriSchemeHttp
  • UriSchemeHttps
  • UriSchemeMailto
  • UriSchemeNetPipe
  • UriSchemeNetTcp
  • UriSchemeNews
  • UriSchemeNntp

I, however, think that this list is out of date and that the following URI Schemes would be a good addition for the .NET 5 era:

UriSchemeTelnet = "telnet" might be considered for interaction with legacy systems.

Proposal

Extend the list of well-known Uri schemes with more commonly used schemes.

namespace System
{
    public class Uri
    {
        // Existing
        public static readonly string UriSchemeFile;
        public static readonly string UriSchemeFtp;
        public static readonly string UriSchemeGopher;
        public static readonly string UriSchemeHttp;
        public static readonly string UriSchemeHttps;
        public static readonly string UriSchemeMailto;
        public static readonly string UriSchemeNews;
        public static readonly string UriSchemeNntp;
        public static readonly string UriSchemeNetTcp;
        public static readonly string UriSchemeNetPipe;

        // Proposed
        public static readonly string UriSchemeWs;
        public static readonly string UriSchemeWss;
        public static readonly string UriSchemeSsh;
        public static readonly string UriSchemeTelnet;
        public static readonly string UriSchemeSftp; // SSH File Transfer Protocol
        public static readonly string UriSchemeFtps; // FTP over SSL
    }
}
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Apr 19, 2020
@ghost
Copy link

ghost commented Apr 19, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@ArthurHNL ArthurHNL changed the title Missing UriScheme Properties: FTPS, WS, WSS Addd UriScheme Properties: SSH, FTPS, SFTP, WS, WSS Apr 19, 2020
@ArthurHNL ArthurHNL changed the title Addd UriScheme Properties: SSH, FTPS, SFTP, WS, WSS Add UriScheme Properties: SSH, FTPS, SFTP, WS, WSS Apr 19, 2020
@scalablecory scalablecory added api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed untriaged New issue has not been triaged by the area owner labels Apr 20, 2020
@scalablecory scalablecory added this to the Future milestone Apr 20, 2020
@scalablecory
Copy link
Contributor

I'm okay with adding these APIs. We should look to see if any other common schemes could be added at the same time. @MihaZupan what do you think?

@MihaZupan
Copy link
Member

MihaZupan commented Apr 20, 2020

I think it makes sense adding them.

Ws, Wss and Telnet already exist, just aren't publicly exposed.

The idea of this list of schemes is that Uri has built-in knowledge of them to provide validation and avoid an allocation of the scheme string when parsing.
Adding more validation to new schemes now would be a breaking change (likely acceptable), but we can at the very least avoid the scheme string allocation.

Should any other schemes be considered? data comes to mind.

@ArthurHNL
Copy link
Author

IANA maintains a list of all official URI schemes. Surprisingly, ftps is not on the list, yet spotify and steam are.

@karelz
Copy link
Member

karelz commented Apr 20, 2020

So what is the value of these APIs? Just to save 1 memory allocation? Is it really worth it?

@MihaZupan
Copy link
Member

So what is the value of these APIs? Just to save 1 memory allocation?

No, this is to provide a list of common well-known Uri schemes (akin to MediaTypeNames #1489).

Whether to use the optimization of saving the scheme allocation is completely up to Uri - an implementation detail that currently holds true for schemes in this list (and ws, wss, telnet).

@MihaZupan MihaZupan added api-ready-for-review and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Apr 22, 2020
@MihaZupan
Copy link
Member

@ArthurHNL I've edited your post with the proposal template and the API has been added to the review backlog.

@karelz karelz changed the title Add UriScheme Properties: SSH, FTPS, SFTP, WS, WSS [Uri] Add UriScheme Properties: SSH, FTPS, SFTP, WS, WSS May 6, 2020
@carlossanlop carlossanlop added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed api-ready-for-review labels Jul 6, 2020
@terrajobst terrajobst added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for review, it is NOT ready for implementation labels Aug 7, 2020
@terrajobst
Copy link
Member

terrajobst commented Aug 7, 2020

Video

  • The names and API shape makes sense.
  • The only concern that we have is whether supporting those schemes has any implications on other parts of URI, such as in UriParser and populating defaults, such as ports. Is there any extra work we'd be signing up to support those? If so, we may want to be more selective what we support. @dotnet/ncl, could you double check?
namespace System
{
    public partial class Uri
    {
        public static readonly string UriSchemeWs;
        public static readonly string UriSchemeWss;
        public static readonly string UriSchemeSsh;
        public static readonly string UriSchemeTelnet;
        public static readonly string UriSchemeSftp;
        public static readonly string UriSchemeFtps;
    }
}

@poke
Copy link
Contributor

poke commented Oct 13, 2020

Hey, I just wanted to let you know that I began working on this in #43375. I’m still struggling a bit with the build system but will add tests later. I would be happy about some early feedback though!

@scalablecory
Copy link
Contributor

Thanks @poke, let me assign the issue to you. Please ask questions if you have any!

@poke
Copy link
Contributor

poke commented Oct 17, 2020

The PR was merged so this issue can be closed 😊

@MihaZupan
Copy link
Member

Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
@karelz karelz modified the milestones: Future, 6.0.0 Jan 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Net
Projects
None yet
Development

No branches or pull requests

8 participants