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

Valid port numbers not representable #275

Closed
Fryie opened this issue Aug 28, 2018 · 6 comments
Closed

Valid port numbers not representable #275

Fryie opened this issue Aug 28, 2018 · 6 comments
Assignees
Milestone

Comments

@Fryie
Copy link

Fryie commented Aug 28, 2018

The ClientRequest.Options enum assumes that port numbers will be represented by a signed 16-bit integer. However, valid port numbers are actually unsigned 16-bit integers.

This means that port numbers 32768-65535 (which are supposed to be valid) cannot be represented. In particular, it means that all dynamic ports won't work.

@ianpartridge
Copy link
Collaborator

Thank you for reporting this limitation. We are aware of this problem - unfortunately as changing the type of a public enum's associated value case is a SemVer Major change we are stuck with this until we decide to do Kitura-net 3.0.0.

We don't have any current plans to do so as the server-side ecosystem including Kitura is migrating to https://github.com/apple/swift-nio and hence Kitura-net is gradually becoming obsolete.

So unless anyone can think of a way we can fix this without breaking SemVer Major, this is probably WONTFIX :(

@Fryie
Copy link
Author

Fryie commented Aug 28, 2018

Thanks for the response. Maybe an ugly fix/workaround could be to introduce a new enum ClientRequest.NewOptions (or whatever) and add an overloaded function like HTTP.request(_ options: NewOptions)? I don't know how feasible / acceptable that would be.

@ianpartridge
Copy link
Collaborator

🤢 😀

@djones6
Copy link
Contributor

djones6 commented Jan 2, 2019

@ianpartridge I recently ran into this, and was considering the workaround proposed above. I agree it would be ugly to introduce a 'new' API, however we wouldn't have to live with it indefinitely, and could fix it properly in the next Kitura-net / Kitura-NIO major.

This issue also affects Kitura-CouchDB since it is built on top of ClientRequest.

@djones6
Copy link
Contributor

djones6 commented Jan 4, 2019

@pushkarnk proposed a neat workaround for this in Kitura/Kitura-NIO#140 which I've replicated in #285. @Fryie would this be sufficient for now?

@djones6
Copy link
Contributor

djones6 commented Jan 7, 2019

Kitura-net 2.1.4 and Kitura-NIO 1.0.9 have been tagged with #285 which provides this workaround:

In order to pass a port number greater than 32,767 (Int16.max), use the following code:

let portNumber: UInt16 = 65535
let portOption: ClientRequest.Options = .port(Int16(bitPattern: portNumber))

@djones6 djones6 closed this as completed Jan 7, 2019
@djones6 djones6 self-assigned this Jan 7, 2019
@djones6 djones6 added this to the 2018.26 milestone Jan 7, 2019
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

No branches or pull requests

3 participants