Repository navigation
strengthen contracts on response-code and response-seconds - #61
Merged
Merged
Conversation
Previously, both accepted `number?`, which was too permissive.
This commit adds `response-code/c`, which is defined as
`(integer-in 100 999)` per [RFC 2616 §6.1.1][1] ("The Status-Code
element is a 3-digit integer ...").
The contract for `response-seconds` is `real?`, which is the
range of `seconds->date` (which is used internally to generate the
`Last-Modified` header).
[1]: https://tools.ietf.org/html/rfc2616#section-6.1.1
Contributor
Author
|
This pull request also bumps the version number for |
LiberalArtist
added a commit
to LiberalArtist/typed-racket
that referenced
this pull request
Apr 4, 2019
- Weaken the types of `response-output` and the `#:output` argument to `response/output` from `Void` to `Any`, corresponding to <racket/web-server@a93685> and v1.2 of the `web-server-lib`. The return type should really be `AnyValues` to match the contract `any`, but Typed Racket can't generate a contract for `AnyValues`. - Update the types for cookie-related functions to reflect the re-implementation based on `net/cookies/server` from <racket/web-server@7974d4d>. This commit adds only as much of `typed/net/cookies/server` and `typed/net/cookies/common` as needed for `typed/web-server/http`. - Document that `net/cookie` is deprecated. - Update the types for `valid-id-cookie?` and `request-id-cookie` to support the `#:shelf-life` argument added in <racket/web-server@626ad02>. - Add the value `temporarily/same-method` with the type `Redirection-Status`, corresponding to <racket/web-server@4601f4>. - Correct the types of `response-seconds` and the corresponding arguments to `response/full`, `response/output`, and `response/xexpr` to use `Real`. While this corresponds to <racket/web-server#61>, using response values containing complex numbers would cause runtime errors even before this: the `response-seconds` is passed to `seconds->date`.
LiberalArtist
force-pushed
the
response-contract
branch
from
April 4, 2019 07:13
4157b98 to
54856c9
Compare
LiberalArtist
commented
Apr 4, 2019
| @bold{is not guaranteed to be an integer.} | ||
|
|
||
| @history[#:changed "1.3" | ||
| "Weakened result contract to allow any number."] |
Contributor
Author
There was a problem hiding this comment.
I do not understand the rationale behind 4cfb68e (I couldn't find a PR 15447), but that is what it did.
LiberalArtist
force-pushed
the
response-contract
branch
from
April 4, 2019 07:25
54856c9 to
bc260a9
Compare
Contributor
|
Thank you, this is great |
LiberalArtist
added a commit
to LiberalArtist/typed-racket
that referenced
this pull request
Apr 4, 2019
- Weaken the types of `response-output` and the `#:output` argument to `response/output` from `Void` to `Any`, corresponding to <racket/web-server@a93685> and v1.2 of the `web-server-lib`. The return type should really be `AnyValues` to match the contract `any`, but Typed Racket can't generate a contract for `AnyValues`. - Update the types for cookie-related functions to reflect the re-implementation based on `net/cookies/server` from <racket/web-server@7974d4d>. This commit adds only as much of `typed/net/cookies/server` and `typed/net/cookies/common` as needed for `typed/web-server/http`. - Document that `net/cookie` is deprecated. - Update the types for `valid-id-cookie?` and `request-id-cookie` to support the `#:shelf-life` argument added in <racket/web-server@626ad02>. - Add the value `temporarily/same-method` with the type `Redirection-Status`, corresponding to <racket/web-server@4601f4>. - Correct the types of `response-seconds` and the corresponding arguments to `response/full`, `response/output`, and `response/xexpr` to use `Real`. While this corresponds to <racket/web-server#61>, using response values containing complex numbers would cause runtime errors even before this: the `response-seconds` is passed to `seconds->date`.
LiberalArtist
added a commit
to LiberalArtist/typed-racket
that referenced
this pull request
Apr 4, 2019
- Weaken the types of `response-output` and the `#:output` argument to `response/output` from `Void` to `Any`, corresponding to <racket/web-server@a93685> and v1.2 of the `web-server-lib`. The return type should really be `AnyValues` to match the contract `any`, but Typed Racket can't generate a contract for `AnyValues`. - Update the types for cookie-related functions to reflect the re-implementation based on `net/cookies/server` from <racket/web-server@7974d4d>. This commit adds only as much of `typed/net/cookies/server` and `typed/net/cookies/common` as needed for `typed/web-server/http`. - Document that `net/cookie` is deprecated. - Update the types for `valid-id-cookie?` and `request-id-cookie` to support the `#:shelf-life` argument added in <racket/web-server@626ad02>. - Add the value `temporarily/same-method` with the type `Redirection-Status`, corresponding to <racket/web-server@4601f4>. - Correct the types of `response-seconds` and the corresponding arguments to `response/full`, `response/output`, and `response/xexpr` to use `Real`. While this corresponds to <racket/web-server#61>, using response values containing complex numbers would cause runtime errors even before this: the `response-seconds` is passed to `seconds->date`.
samth
pushed a commit
to racket/typed-racket
that referenced
this pull request
Apr 10, 2019
- Weaken the types of `response-output` and the `#:output` argument to `response/output` from `Void` to `Any`, corresponding to <racket/web-server@a93685> and v1.2 of the `web-server-lib`. The return type should really be `AnyValues` to match the contract `any`, but Typed Racket can't generate a contract for `AnyValues`. - Update the types for cookie-related functions to reflect the re-implementation based on `net/cookies/server` from <racket/web-server@7974d4d>. This commit adds only as much of `typed/net/cookies/server` and `typed/net/cookies/common` as needed for `typed/web-server/http`. - Document that `net/cookie` is deprecated. - Update the types for `valid-id-cookie?` and `request-id-cookie` to support the `#:shelf-life` argument added in <racket/web-server@626ad02>. - Add the value `temporarily/same-method` with the type `Redirection-Status`, corresponding to <racket/web-server@4601f4>. - Correct the types of `response-seconds` and the corresponding arguments to `response/full`, `response/output`, and `response/xexpr` to use `Real`. While this corresponds to <racket/web-server#61>, using response values containing complex numbers would cause runtime errors even before this: the `response-seconds` is passed to `seconds->date`.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, both accepted
number?, which was too permissive.This commit adds
response-code/c, which is defined as(integer-in 100 999)per RFC 2616 §6.1.1 ("The Status-Codeelement is a 3-digit integer ...").
The contract for
response-secondsisreal?, which is therange of
seconds->date(which is used internally to generate theLast-Modifiedheader).