File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
src/jdk.httpserver/share/classes/com/sun/net/httpserver
test/jdk/com/sun/net/httpserver/bugs/8199849 Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,7 @@ public Result authenticate (HttpExchange t)
95
95
*/
96
96
String auth = rmap .getFirst ("Authorization" );
97
97
if (auth == null ) {
98
- Headers map = t .getResponseHeaders ();
99
- var authString = "Basic realm=" + "\" " + realm + "\" " +
100
- (isUTF8 ? " charset=\" UTF-8\" " : "" );
101
- map .set ("WWW-Authenticate" , authString );
98
+ setAuthHeader (t );
102
99
return new Authenticator .Retry (401 );
103
100
}
104
101
int sp = auth .indexOf (' ' );
@@ -119,13 +116,18 @@ public Result authenticate (HttpExchange t)
119
116
);
120
117
} else {
121
118
/* reject the request again with 401 */
122
-
123
- Headers map = t .getResponseHeaders ();
124
- map .set ("WWW-Authenticate" , "Basic realm=" + "\" " +realm +"\" " );
119
+ setAuthHeader (t );
125
120
return new Authenticator .Failure (401 );
126
121
}
127
122
}
128
123
124
+ private void setAuthHeader (HttpExchange t ) {
125
+ Headers map = t .getResponseHeaders ();
126
+ var authString = "Basic realm=" + "\" " + realm + "\" " +
127
+ (isUTF8 ? ", charset=\" UTF-8\" " : "" );
128
+ map .set ("WWW-Authenticate" , authString );
129
+ }
130
+
129
131
/**
130
132
* called for each incoming request to verify the
131
133
* given name and password in the context of this
Original file line number Diff line number Diff line change 32
32
33
33
/**
34
34
* @test
35
- * @bug 8199849
35
+ * @bug 8199849 8235976
36
36
* @summary
37
37
* @library /test/lib
38
38
* @run main/othervm ParamTest
42
42
public class ParamTest {
43
43
44
44
static final String [] variants = {
45
- " charset=utf-8" ,
46
- " charset=UtF-8" ,
47
- " charset=\" utF-8\" " ,
48
- " charset=\" UtF-8\" "
45
+ " , charset=utf-8" ,
46
+ " , charset=UtF-8" ,
47
+ " , charset=\" utF-8\" " ,
48
+ " , charset=\" UtF-8\" "
49
49
};
50
50
51
51
static final int LOOPS = variants .length ;
You can’t perform that action at this time.
0 commit comments