-
Notifications
You must be signed in to change notification settings - Fork 18
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
Something subtle has changed in .pairup, this fixes it #99
base: master
Are you sure you want to change the base?
Conversation
Could you give us a p6w app that emits an error in |
It fails the t/Crust-Middleware/lint.t 👍
But the actual reason isn't evident because the CATCH in the block there, if the exception is printed in the default case there it becomes evident that every invocation of
This only gives rise to one test failure because the remainder of the tests expect it do throw some exception, but doesn't check what exception :) I may have a deeper look at this later because there's a possibility that those tests are passing accidentally because the resulting exceptions aren't being checked very deeply. |
I confirmed that t/Crust-Middleware/lint.t failed; we can reduce that failure to a simple case:
According to the spec of P6W and an implementation of P6W server, So I think we should check that by something like diff --git lib/Crust/Middleware/Lint.pm6 lib/Crust/Middleware/Lint.pm6
index 892e7a9..0c490b7 100644
--- lib/Crust/Middleware/Lint.pm6
+++ lib/Crust/Middleware/Lint.pm6
@@ -63,13 +63,8 @@ my sub validate-ret(@ret) {
my $copy = @ret[1];
- {
- $copy.pairup();
- CATCH {
- default {
- die 'The number of response headers needs to be even, not odd(', $copy, ')';
- }
- }
+ unless all(@($copy)) ~~ Pair {
+ die 'Response headers must be a List of Pairs, but ', $copy;
}
for $copy.kv -> $i, $v {
diff --git t/Crust-Middleware/lint.t t/Crust-Middleware/lint.t
index d4ffd2b..8fbd17e 100644
--- t/Crust-Middleware/lint.t
+++ t/Crust-Middleware/lint.t
@@ -146,7 +146,7 @@ subtest {
sub (%env) { start { 200, ['invalid'], ['hello'] } }
);
dies-ok({await $code(%env)});
- }, 'Should die because response header has odd elements';
+ }, 'Should die because response header is not a List of Pairs';
subtest {
my $code = Crust::Middleware::Lint.new( |
The spec also says that
What does "coerced" mean here? :) |
I guess you could have a type that implements a The previous implementation would allow an even sized list of key, value items to be acceptable. So |
Not quite sure what has changed in .pairup but it was getting
when it encountered the pairs in the headers. This papers over that for the time being.