Skip to content

Commit 638b1d9

Browse files
committed
84 specs passed, 17 more to go
1 parent f99af1f commit 638b1d9

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

lib/fsm.iced

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class FSM
170170
return null if dateStr == null || dateStr == ''
171171
date = new Date(dateStr)
172172
date = null if isNaN(date.getTime())
173+
date
173174

174175
# TODO: encode this body
175176
encodeBody: (req, res) =>
@@ -648,14 +649,14 @@ class FSM
648649
if req.method == 'GET' || req.method == 'HEAD'
649650
# TODO: call these async
650651
@resource.generateEtag req, res, (etag) =>
651-
res.header["ETag"] = "\"#{etag}\"" if etag
652+
res.headers["ETag"] = "\"#{etag}\"" if etag
652653

653654
@resource.lastModified req, res, (lastModified) =>
654-
res.header["Last-Modified"] = new Date(lastModified) if lastModified
655+
res.headers["Last-Modified"] = new Date(lastModified) if lastModified
655656
# httpdUtil:rfc1123Date(calendar:universalTimeToLocalTime(LM))
656657

657658
@resource.expires req, res, (expires) =>
658-
res.header["Expires"] = new Date(expires) if expires
659+
res.headers["Expires"] = new Date(expires) if expires
659660
# httpdUtil:rfc1123Date(calendar:universalTimeToLocalTime(Exp))})
660661

661662
contentTypes = @resource.contentTypesProvidedSync(req, res)

test/scenarios.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ module.exports = [
555555
},
556556
{
557557
name: "v3g7 true",
558-
appConfig: { resourceExists: true, resourceEtag: "yyy" },
558+
appConfig: { resourceExists: true, generateEtag: "yyy" },
559559
method: "GET",
560560
path: "/",
561561
headers: { "If-match": "xxx" },
@@ -564,7 +564,7 @@ module.exports = [
564564
},
565565
{
566566
name: "v3g9 false",
567-
appConfig: { resourceExists: true, resourceEtag: "yyy" },
567+
appConfig: { resourceExists: true, generateEtag: "yyy" },
568568
method: "GET",
569569
path: "/",
570570
headers: { "If-match": "xxx" },
@@ -573,7 +573,7 @@ module.exports = [
573573
},
574574
{
575575
name: "v3g9 true",
576-
appConfig: { resourceExists: true, resourceModified: new Date("2009/11/28 5:23:02 AM") },
576+
appConfig: { resourceExists: true, lastModified: new Date("2009/11/28 5:23:02 AM") },
577577
method: "GET",
578578
path: "/",
579579
headers: { "If-match": "*", "If-Unmodified-Since": "Fri, 28 Nov 1975 10:23:02 GMT" },
@@ -582,7 +582,7 @@ module.exports = [
582582
},
583583
{
584584
name: "v3g11 false",
585-
appConfig: { resourceExists: true, resourceEtag: "yyy" },
585+
appConfig: { resourceExists: true, generateEtag: "yyy" },
586586
method: "GET",
587587
path: "/",
588588
headers: { "If-match": "xxx" },
@@ -591,7 +591,7 @@ module.exports = [
591591
},
592592
{
593593
name: "v3g11 true",
594-
appConfig: { resourceExists: true, resourceEtag: "xxx", resourceModified: new Date("2009/11/28 5:23:02 AM") },
594+
appConfig: { resourceExists: true, generateEtag: "xxx", lastModified: new Date("2009/11/28 5:23:02 AM") },
595595
method: "GET",
596596
path: "/",
597597
headers: { "If-match": "xxx", "If-Unmodified-Since": "Fri, 28 Nov 1975 10:23:02 GMT" },
@@ -609,7 +609,7 @@ module.exports = [
609609
},
610610
{
611611
name: "v3h12 true",
612-
appConfig: { resourceExists: true, resourceEtag: "xxx", resourceModified: new Date("2009/11/28 5:23:02 AM") },
612+
appConfig: { resourceExists: true, generateEtag: "xxx", lastModified: new Date("2009/11/28 5:23:02 AM") },
613613
method: "GET",
614614
path: "/",
615615
headers: { "If-match": "xxx", "If-Unmodified-Since": "Fri, 28 Nov 1975 10:23:02 GMT" },
@@ -618,7 +618,7 @@ module.exports = [
618618
},
619619
{
620620
name: "v3h12 false",
621-
appConfig: { resourceModified: new Date("1975/11/28 5:23:02 AM") },
621+
appConfig: { lastModified: new Date("1975/11/28 5:23:02 AM") },
622622
method: "GET",
623623
path: "/",
624624
headers: { "If-Unmodified-Since": "Sat, 28 Nov 2009 10:23:02 GMT", "If-None-Match": "*" },
@@ -636,7 +636,7 @@ module.exports = [
636636
},
637637
{
638638
name: "v3i13 false",
639-
appConfig: { resourceEtag: "xxx" },
639+
appConfig: { generateEtag: "xxx" },
640640
method: "GET",
641641
path: "/",
642642
headers: { "If-None-Match": "xxx" },
@@ -645,7 +645,7 @@ module.exports = [
645645
},
646646
{
647647
name: "v3k13 true",
648-
appConfig: { resourceEtag: "xxx" },
648+
appConfig: { generateEtag: "xxx" },
649649
method: "GET",
650650
path: "/",
651651
headers: { "If-None-Match": "xxx" },
@@ -681,7 +681,7 @@ module.exports = [
681681
},
682682
{
683683
name: "v3k13 false",
684-
appConfig: { resourceEtag: "yyy", resourceModified: new Date("1975/11/28 5:23:02 AM") },
684+
appConfig: { generateEtag: "yyy", lastModified: new Date("1975/11/28 5:23:02 AM") },
685685
method: "GET",
686686
path: "/",
687687
headers: { "If-None-Match": "xxx", "If-Modified-Since": "Sat, 28 Nov 2009 10:23:02 GMT" },
@@ -690,7 +690,7 @@ module.exports = [
690690
},
691691
{
692692
name: "v3l14 false",
693-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: false },
693+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: false },
694694
method: "DELETE",
695695
path: "/",
696696
headers: { "If-Modified-Since": "smdgfshdgfhjsgdfjsnfd" },
@@ -699,7 +699,7 @@ module.exports = [
699699
},
700700
{
701701
name: "v3l15 true",
702-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: false },
702+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: false },
703703
method: "DELETE",
704704
path: "/",
705705
headers: { "If-Modified-Since": "Wed, 28 Nov 2029 10:23:02 GMT" },
@@ -708,7 +708,7 @@ module.exports = [
708708
},
709709
{
710710
name: "v3l17 true",
711-
appConfig: { resourceModified: new Date("2009/11/28 5:23:02 AM"), allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: false },
711+
appConfig: { lastModified: new Date("2009/11/28 5:23:02 AM"), allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: false },
712712
method: "DELETE",
713713
path: "/",
714714
headers: { "If-Modified-Since": "Fri, 28 Nov 1975 10:23:02 GMT" },
@@ -717,7 +717,7 @@ module.exports = [
717717
},
718718
{
719719
name: "v3l17 false",
720-
appConfig: { resourceModified: new Date("1975/11/28 5:23:02 AM") },
720+
appConfig: { lastModified: new Date("1975/11/28 5:23:02 AM") },
721721
method: "GET",
722722
path: "/",
723723
headers: { "If-Modified-Since": "Sat, 28 Nov 2009 10:23:02 GMT" },
@@ -726,7 +726,7 @@ module.exports = [
726726
},
727727
{
728728
name: "v3m16 true",
729-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: false },
729+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: false },
730730
method: "DELETE",
731731
path: "/",
732732
headers: { },
@@ -735,7 +735,7 @@ module.exports = [
735735
},
736736
{
737737
name: "v3m16 false",
738-
appConfig: { deleteResource: true, deleteComplete: false },
738+
appConfig: { deleteResource: true, deleteCompleted: false },
739739
method: "GET",
740740
path: "/",
741741
headers: { },
@@ -744,7 +744,7 @@ module.exports = [
744744
},
745745
{
746746
name: "v3n16 false",
747-
appConfig: { deleteResource: true, deleteComplete: false },
747+
appConfig: { deleteResource: true, deleteCompleted: false },
748748
method: "GET",
749749
path: "/",
750750
headers: { },
@@ -753,7 +753,7 @@ module.exports = [
753753
},
754754
{
755755
name: "v3n16 true",
756-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
756+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
757757
method: "POST",
758758
path: "/",
759759
headers: { },
@@ -762,7 +762,7 @@ module.exports = [
762762
},
763763
{
764764
name: "v3n11 true (redirect)",
765-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", redirectAfterPost: true, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
765+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", redirectAfterPost: true, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
766766
method: "POST",
767767
path: "/",
768768
headers: { },
@@ -771,7 +771,7 @@ module.exports = [
771771
},
772772
{
773773
name: "v3n11 true (no redirect)",
774-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", redirectAfterPost: false, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
774+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: true, createPath: "/", redirectAfterPost: false, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
775775
method: "POST",
776776
path: "/",
777777
headers: { },
@@ -780,7 +780,7 @@ module.exports = [
780780
},
781781
{
782782
name: "v3n11 false",
783-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
783+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
784784
method: "POST",
785785
path: "/",
786786
headers: { },
@@ -807,7 +807,7 @@ module.exports = [
807807
},
808808
{
809809
name: "v3p11 true",
810-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
810+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
811811
method: "POST",
812812
path: "/",
813813
headers: { },
@@ -816,7 +816,7 @@ module.exports = [
816816
},
817817
{
818818
name: "v3p11 false",
819-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { return(true) } },
819+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['POST'], postIsCreate: false, processPost: function (context) { return(true) } },
820820
method: "POST",
821821
path: "/",
822822
headers: { },
@@ -825,7 +825,7 @@ module.exports = [
825825
},
826826
{
827827
name: "v3o16 false",
828-
appConfig: { deleteResource: true, deleteComplete: false },
828+
appConfig: { deleteResource: true, deleteCompleted: false },
829829
method: "GET",
830830
path: "/",
831831
headers: { },
@@ -834,7 +834,7 @@ module.exports = [
834834
},
835835
{
836836
name: "v3o16 true",
837-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['PUT'], isConflict: true },
837+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['PUT'], isConflict: true },
838838
method: "PUT",
839839
path: "/",
840840
headers: { },
@@ -843,7 +843,7 @@ module.exports = [
843843
},
844844
{
845845
name: "v3o14 true",
846-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['PUT'], isConflict: true },
846+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['PUT'], isConflict: true },
847847
method: "PUT",
848848
path: "/",
849849
headers: { },
@@ -852,7 +852,7 @@ module.exports = [
852852
},
853853
{
854854
name: "v3o14 false",
855-
appConfig: { deleteResource: true, deleteComplete: false, allowedMethodsSync: ['PUT'], isConflict: false, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
855+
appConfig: { deleteResource: true, deleteCompleted: false, allowedMethodsSync: ['PUT'], isConflict: false, acceptContent: function (context) { context.res.setHeader("Location", "/foo"); return(true) } },
856856
method: "PUT",
857857
path: "/",
858858
headers: { },
@@ -861,7 +861,7 @@ module.exports = [
861861
},
862862
{
863863
name: "v3o18 false",
864-
appConfig: { deleteResource: true, deleteComplete: false },
864+
appConfig: { deleteResource: true, deleteCompleted: false },
865865
method: "GET",
866866
path: "/",
867867
headers: { },
@@ -870,7 +870,7 @@ module.exports = [
870870
},
871871
{
872872
name: "v3o18 true",
873-
appConfig: { deleteResource: true, deleteComplete: false, multipleChoices: true },
873+
appConfig: { deleteResource: true, deleteCompleted: false, multipleChoices: true },
874874
method: "GET",
875875
path: "/",
876876
headers: { },
@@ -879,7 +879,7 @@ module.exports = [
879879
},
880880
{
881881
name: "v3m20 false",
882-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: false },
882+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: false },
883883
method: "DELETE",
884884
path: "/",
885885
headers: { },
@@ -888,7 +888,7 @@ module.exports = [
888888
},
889889
{
890890
name: "v3o20 false",
891-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: true, responseEntityExists: false },
891+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: true, responseEntityExists: false },
892892
method: "DELETE",
893893
path: "/",
894894
headers: { },
@@ -897,7 +897,7 @@ module.exports = [
897897
},
898898
{
899899
name: "v3o20 true",
900-
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteComplete: true, responseEntityExists: true },
900+
appConfig: { allowedMethodsSync: ['DELETE'], deleteResource: true, deleteCompleted: true, responseEntityExists: true },
901901
method: "DELETE",
902902
path: "/",
903903
headers: { },
@@ -906,7 +906,7 @@ module.exports = [
906906
},
907907
{
908908
name: "Send ETag",
909-
appConfig: { resourceEtag: "xxx" },
909+
appConfig: { generateEtag: "xxx" },
910910
method: "GET",
911911
path: "/",
912912
headers: { },

0 commit comments

Comments
 (0)