@@ -143,27 +143,27 @@ void serverShouldAcceptGoodDoubleDotPatterns(String pattern) {
143
143
void dotsAndEqualsInNameValueQuery () {
144
144
QUERY_SEPARATORS .forEach (qs -> {
145
145
assertThat (forServer ("/?a=..=" + qs + "b=..=" )).satisfies (res -> {
146
- assertThat (res ).isNotNull ();
147
- assertThat (res .query ()).isEqualTo ("a=..=" + qs + "b=..=" );
148
- assertThat (QueryParams .fromQueryString (res .query (), true )).containsExactly (
146
+ assertThat (res . requestTarget ).isNotNull ();
147
+ assertThat (res .requestTarget . query ()).isEqualTo ("a=..=" + qs + "b=..=" );
148
+ assertThat (QueryParams .fromQueryString (res .requestTarget . query (), true )).containsExactly (
149
149
Maps .immutableEntry ("a" , "..=" ),
150
150
Maps .immutableEntry ("b" , "..=" )
151
151
);
152
152
});
153
153
154
154
assertThat (forServer ("/?a==.." + qs + "b==.." )).satisfies (res -> {
155
155
assertThat (res ).isNotNull ();
156
- assertThat (res .query ()).isEqualTo ("a==.." + qs + "b==.." );
157
- assertThat (QueryParams .fromQueryString (res .query (), true )).containsExactly (
156
+ assertThat (res .requestTarget . query ()).isEqualTo ("a==.." + qs + "b==.." );
157
+ assertThat (QueryParams .fromQueryString (res .requestTarget . query (), true )).containsExactly (
158
158
Maps .immutableEntry ("a" , "=.." ),
159
159
Maps .immutableEntry ("b" , "=.." )
160
160
);
161
161
});
162
162
163
163
assertThat (forServer ("/?a==..=" + qs + "b==..=" )).satisfies (res -> {
164
164
assertThat (res ).isNotNull ();
165
- assertThat (res .query ()).isEqualTo ("a==..=" + qs + "b==..=" );
166
- assertThat (QueryParams .fromQueryString (res .query (), true )).containsExactly (
165
+ assertThat (res .requestTarget . query ()).isEqualTo ("a==..=" + qs + "b==..=" );
166
+ assertThat (QueryParams .fromQueryString (res .requestTarget . query (), true )).containsExactly (
167
167
Maps .immutableEntry ("a" , "=..=" ),
168
168
Maps .immutableEntry ("b" , "=..=" )
169
169
);
@@ -500,9 +500,9 @@ void clientShouldAcceptAbsoluteUri(String uri,
500
500
String expectedScheme , String expectedAuthority , String expectedPath ,
501
501
@ Nullable String expectedQuery , @ Nullable String expectedFragment ) {
502
502
503
- final RequestTarget res = forClient (uri );
504
- assertThat (res .scheme ()).isEqualTo (expectedScheme );
505
- assertThat (res .authority ()).isEqualTo (expectedAuthority );
503
+ final RequestTargetWithRawPath res = forClient (uri );
504
+ assertThat (res .requestTarget . scheme ()).isEqualTo (expectedScheme );
505
+ assertThat (res .requestTarget . authority ()).isEqualTo (expectedAuthority );
506
506
assertAccepted (res , expectedPath , emptyToNull (expectedQuery ), emptyToNull (expectedFragment ));
507
507
}
508
508
@@ -531,15 +531,15 @@ void shouldYieldEmptyStringForEmptyQueryAndFragment(Mode mode) {
531
531
@ ParameterizedTest
532
532
@ EnumSource (Mode .class )
533
533
void testToString (Mode mode ) {
534
- assertThat (parse (mode , "/" )).asString ().isEqualTo ("/" );
535
- assertThat (parse (mode , "/?" )).asString ().isEqualTo ("/?" );
536
- assertThat (parse (mode , "/?a=b" )).asString ().isEqualTo ("/?a=b" );
534
+ assertThat (parse (mode , "/" ). requestTarget ).asString ().isEqualTo ("/" );
535
+ assertThat (parse (mode , "/?" ). requestTarget ).asString ().isEqualTo ("/?" );
536
+ assertThat (parse (mode , "/?a=b" ). requestTarget ).asString ().isEqualTo ("/?a=b" );
537
537
538
538
if (mode == Mode .CLIENT ) {
539
- assertThat (forClient ("/#" )).asString ().isEqualTo ("/#" );
540
- assertThat (forClient ("/?#" )).asString ().isEqualTo ("/?#" );
541
- assertThat (forClient ("/?a=b#c=d" )).asString ().isEqualTo ("/?a=b#c=d" );
542
- assertThat (forClient ("http://foo/bar?a=b#c=d" )).asString ().isEqualTo ("http://foo/bar?a=b#c=d" );
539
+ assertThat (forClient ("/#" ). requestTarget ).asString ().isEqualTo ("/#" );
540
+ assertThat (forClient ("/?#" ). requestTarget ).asString ().isEqualTo ("/?#" );
541
+ assertThat (forClient ("/?a=b#c=d" ). requestTarget ).asString ().isEqualTo ("/?a=b#c=d" );
542
+ assertThat (forClient ("http://foo/bar?a=b#c=d" ). requestTarget ).asString ().isEqualTo ("http://foo/bar?a=b#c=d" );
543
543
}
544
544
}
545
545
@@ -572,32 +572,32 @@ void testRemoveMatrixVariables() {
572
572
assertThat (removeMatrixVariables ("/prefix/;a=b" )).isNull ();
573
573
}
574
574
575
- private static void assertAccepted (@ Nullable RequestTarget res , String expectedPath ) {
575
+ private static void assertAccepted (RequestTargetWithRawPath res , String expectedPath ) {
576
576
assertAccepted (res , expectedPath , null , null );
577
577
}
578
578
579
- private static void assertAccepted (@ Nullable RequestTarget res ,
579
+ private static void assertAccepted (RequestTargetWithRawPath res ,
580
580
String expectedPath ,
581
581
@ Nullable String expectedQuery ) {
582
582
assertAccepted (res , expectedPath , expectedQuery , null );
583
583
}
584
584
585
- private static void assertAccepted (@ Nullable RequestTarget res ,
585
+ private static void assertAccepted (RequestTargetWithRawPath res ,
586
586
String expectedPath ,
587
587
@ Nullable String expectedQuery ,
588
588
@ Nullable String expectedFragment ) {
589
- assertThat (res ).isNotNull ();
590
- assertThat (res .path ()).isEqualTo (expectedPath );
591
- assertThat (res .query ()).isEqualTo (expectedQuery );
592
- assertThat (res .fragment ()).isEqualTo (expectedFragment );
589
+ assertThat (res .requestTarget ).isNotNull ();
590
+ assertThat (res .requestTarget .path ()).isEqualTo (expectedPath );
591
+ assertThat (res .requestTarget .query ()).isEqualTo (expectedQuery );
592
+ assertThat (res .requestTarget .fragment ()).isEqualTo (expectedFragment );
593
+ assertThat (res .requestTarget .rawPath ()).isEqualTo (res .rawPath );
593
594
}
594
595
595
- private static void assertRejected (@ Nullable RequestTarget res ) {
596
- assertThat (res ).isNull ();
596
+ private static void assertRejected (RequestTargetWithRawPath res ) {
597
+ assertThat (res . requestTarget ).isNull ();
597
598
}
598
599
599
- @ Nullable
600
- private static RequestTarget parse (Mode mode , String rawPath ) {
600
+ private static RequestTargetWithRawPath parse (Mode mode , String rawPath ) {
601
601
switch (mode ) {
602
602
case SERVER :
603
603
return forServer (rawPath );
@@ -608,37 +608,57 @@ private static RequestTarget parse(Mode mode, String rawPath) {
608
608
}
609
609
}
610
610
611
- @ Nullable
612
- private static RequestTarget forServer (String rawPath ) {
611
+ private static class RequestTargetWithRawPath {
612
+ @ Nullable
613
+ final String rawPath ;
614
+ @ Nullable
615
+ final RequestTarget requestTarget ;
616
+
617
+ RequestTargetWithRawPath (@ Nullable String rawPath , @ Nullable RequestTarget requestTarget ) {
618
+ this .rawPath = rawPath ;
619
+ this .requestTarget = requestTarget ;
620
+ }
621
+
622
+ @ Override
623
+ public String toString () {
624
+ return "RequestTargetWithRawPath{" +
625
+ "rawPath='" + rawPath + '\'' +
626
+ ", requestTarget=" + requestTarget +
627
+ '}' ;
628
+ }
629
+ }
630
+
631
+ private static RequestTargetWithRawPath forServer (String rawPath ) {
613
632
return forServer (rawPath , false );
614
633
}
615
634
616
- @ Nullable
617
- private static RequestTarget forServer (String rawPath , boolean allowSemicolonInPathComponent ) {
618
- final RequestTarget res = DefaultRequestTarget .forServer (rawPath , allowSemicolonInPathComponent , false );
619
- if (res != null ) {
620
- logger .info ("forServer({}) => path: {}, query: {}" , rawPath , res .path (), res .query ());
635
+ private static RequestTargetWithRawPath forServer (String rawPath , boolean allowSemicolonInPathComponent ) {
636
+ final RequestTarget target = DefaultRequestTarget .forServer (
637
+ rawPath ,
638
+ allowSemicolonInPathComponent ,
639
+ false );
640
+ if (target != null ) {
641
+ logger .info ("forServer({}) => path: {}, query: {}" , rawPath , target .path (), target .query ());
621
642
} else {
622
643
logger .info ("forServer({}) => null" , rawPath );
623
644
}
624
- return res ;
645
+ return new RequestTargetWithRawPath ( rawPath , target ) ;
625
646
}
626
647
627
- @ Nullable
628
- private static RequestTarget forClient (String rawPath ) {
648
+ private static RequestTargetWithRawPath forClient (String rawPath ) {
629
649
return forClient (rawPath , null );
630
650
}
631
651
632
- @ Nullable
633
- private static RequestTarget forClient (String rawPath , @ Nullable String prefix ) {
634
- final RequestTarget res = DefaultRequestTarget . forClient ( rawPath , prefix );
635
- if ( res != null ) {
636
- logger . info ( "forClient({}, {}) => path: {}, query: {}, fragment: {}" , rawPath , prefix , res .path (),
637
- res .query (), res .fragment ());
652
+ private static RequestTargetWithRawPath forClient ( String rawPath , @ Nullable String prefix ) {
653
+ final RequestTarget target = DefaultRequestTarget . forClient (rawPath , prefix );
654
+ if ( target != null ) {
655
+ logger . info ( "forClient({}, {}) => path: {}, query: {}, fragment: {}" ,
656
+ rawPath , prefix , target .path (),
657
+ target .query (), target .fragment ());
638
658
} else {
639
659
logger .info ("forClient({}, {}) => null" , rawPath , prefix );
640
660
}
641
- return res ;
661
+ return new RequestTargetWithRawPath ( null , target ) ;
642
662
}
643
663
644
664
private static String toAbsolutePath (String pattern ) {
0 commit comments