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

HTTPMethod.hasRequestBody .unlikely #151

Closed
helje5 opened this issue Mar 14, 2018 · 11 comments · Fixed by #908
Closed

HTTPMethod.hasRequestBody .unlikely #151

helje5 opened this issue Mar 14, 2018 · 11 comments · Fixed by #908
Labels
fix-proposed There's a fix proposed for this issue and the PR should referenced. ⚠️ needs-major-version-bump For PRs that when merged cause a bump of the major version, ie. x.0.0 -> (x+1).0.0
Milestone

Comments

@helje5
Copy link
Contributor

helje5 commented Mar 14, 2018

The current implementation of hasRequestBody uses unlikely for a lot of cases where a body is actually very likely or a plain .yes (not sure what the different is, a PUT can also have an empty body).

Examples MKCOL, PROPFIND, REPORT, MKCALENDAR, etc.

@weissi weissi added this to the 2.0.0 milestone Nov 27, 2018
@weissi
Copy link
Member

weissi commented Nov 27, 2018

@Lukasa any insights here?

@Lukasa
Copy link
Contributor

Lukasa commented Nov 27, 2018

I'm fine with us changing some cases of .unlikely to .yes where we can find an RFC validating the behaviour.

The issue I suspect @helje5 is mostly bothered by is the word choice. That's fair enough, .unlikely doesn't convey the meaning very well here. The purpose of this field is to decide what transport header rewriting we do, and how that affects framing. In this context, .unlikely means "don't rewrite the headers, let the user make their own bed and lie in it". Put another way, it's the "I don't know" case. We can change the word .unlikely to .unknown if we want whenever we want, the enum is private.

For that matter, if there are RFCs that cover the body requirements for non-HTTP/1.1 methods that we can point to that justify changing .unlikely to either .yes or .no we can also do that whenever we want, as the behavioural change constitutes a bug fix. This isn't a 2.0 issue.

@Lukasa Lukasa removed this from the 2.0.0 milestone Nov 27, 2018
@helje5
Copy link
Contributor Author

helje5 commented Nov 27, 2018

If we tie the HTTPMethod to specific methods anyways, there is actually no reason for .unknown? We can just add the proper values for every single method (PROPFIND, MKCALENDAR etc. - work, but should be done).
This may make .unlikely legit. it is fine for e.g. .GET, but the wrong option for the fallthrough. The fallthrough should be .yes (I think)?

@weissi
Copy link
Member

weissi commented Nov 27, 2018

@Lukasa the enums are public

public enum HTTPMethod: Equatable {
    public enum HasBody {
        case yes
        case no
        case unlikely
    }

    case GET
    case PUT
    case ACL
    case HEAD
    case POST
    case COPY
    case LOCK
    case MOVE
    case BIND
    case LINK
    case PATCH
    case TRACE
    case MKCOL
    case MERGE
    case PURGE
    case NOTIFY
    case SEARCH
    case UNLOCK
    case REBIND
    case UNBIND
    case REPORT
    case DELETE
    case UNLINK
    case CONNECT
    case MSEARCH
    case OPTIONS
    case PROPFIND
    case CHECKOUT
    case PROPPATCH
    case SUBSCRIBE
    case MKCALENDAR
    case MKACTIVITY
    case UNSUBSCRIBE
    case RAW(value: String)

}

@Lukasa
Copy link
Contributor

Lukasa commented Nov 27, 2018

@weissi I'm losing my mind in my old age

@Lukasa Lukasa added this to the 2.0.0 milestone Nov 27, 2018
@Lukasa
Copy link
Contributor

Lukasa commented Nov 27, 2018

@helje5 The problem with having .yes in the fallthrough is that it will cause SwiftNIO to put a Transfer-Encoding header on the request unconditionally if there are no other transport headers in place. That seems like the wrong default for methods we don't understand: they may have the semantics of GET, but we don't know that, and adding TE may get a valid request rejected. .unlikely seems like the right default for the fallthrough: I think we should just expand the switch to be more accurate more of the time.

@weissi
Copy link
Member

weissi commented Feb 25, 2019

we'll make this internal

@weissi weissi added the ⚠️ needs-major-version-bump For PRs that when merged cause a bump of the major version, ie. x.0.0 -> (x+1).0.0 label Mar 18, 2019
@weissi
Copy link
Member

weissi commented Mar 18, 2019

@Lukasa eek, my dashboard didn't show this as it was missing the '⚠️ needs-major-version-bump' label :'(. I quick github search only showed one hit for this: https://github.com/skelpo/JWTMiddleware/blob/466838e04ef1c2fdf7fe234162df5be7a9dfbf6c/Sources/JWTAuthenticatable/BasicJWTAuthenticatable.swift which is a Vapor 3 thing (and therefore NIO 1).

So we could make this internal now and probably not break anybody.

@Lukasa what do you think?

@Lukasa
Copy link
Contributor

Lukasa commented Mar 18, 2019

Let’s do it.

weissi added a commit to weissi/swift-nio that referenced this issue Mar 18, 2019
Motivation:

HTTPMethod.hasRequestBody was unnecessarily public.

Modifications:

make it internal

Result:

fixes apple#151
@weissi weissi added the fix-proposed There's a fix proposed for this issue and the PR should referenced. label Mar 18, 2019
@weissi
Copy link
Member

weissi commented Mar 18, 2019

@Lukasa done

@normanmaurer
Copy link
Member

@weissi sounds good

weissi added a commit that referenced this issue Mar 19, 2019
* make HTTPMethod.hasRequestBody internal

Motivation:

HTTPMethod.hasRequestBody was unnecessarily public.

Modifications:

make it internal

Result:

fixes #151

* Update public-api-changes-NIO1-to-NIO2.md
weissi pushed a commit to weissi/swift-nio that referenced this issue Jun 13, 2020
…pple#175)

Update BadStreamStateTransition to have an enum NIOHTTP2StreamState that shows which state the stream was in before the error.
weissi pushed a commit to weissi/swift-nio that referenced this issue Feb 3, 2024
The 5.6 nightly images are available, let's use them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix-proposed There's a fix proposed for this issue and the PR should referenced. ⚠️ needs-major-version-bump For PRs that when merged cause a bump of the major version, ie. x.0.0 -> (x+1).0.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants