@@ -168,9 +168,9 @@ public int status() {
168168 }
169169
170170 /**
171- * Nullable and not set when using http/2
172- *
173- * <p>See https://github.com/http2/http2-spec/issues/202
171+ * Nullable and not set when using http/2 See <a
172+ * href="/http2/http2-spec/issues/202">...</a> See <a
173+ * href=" https://github.com/http2/http2-spec/issues/202">...</a>
174174 */
175175 public String reason () {
176176 return reason ;
@@ -200,6 +200,12 @@ public ProtocolVersion protocolVersion() {
200200 return protocolVersion ;
201201 }
202202
203+ /**
204+ * Returns a charset object based on the requests content type. Defaults to UTF-8 See <a
205+ * href="https://datatracker.ietf.org/doc/html/rfc7231#section-5.3.3">rfc7231 - Accept-Charset</a>
206+ * See <a href="https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.1.1">rfc7231 - Media
207+ * Type</a>
208+ */
203209 public Charset charset () {
204210
205211 Collection <String > contentTypeHeaders = headers ().get ("Content-Type" );
@@ -210,7 +216,8 @@ public Charset charset() {
210216 if (contentTypeParmeters .length > 1 ) {
211217 String [] charsetParts = contentTypeParmeters [1 ].split ("=" );
212218 if (charsetParts .length == 2 && "charset" .equalsIgnoreCase (charsetParts [0 ].trim ())) {
213- return Charset .forName (charsetParts [1 ]);
219+ String charsetString = charsetParts [1 ].replaceAll ("\" " , "" );
220+ return Charset .forName (charsetString );
214221 }
215222 }
216223 }
@@ -309,7 +316,7 @@ public Reader asReader() {
309316 }
310317
311318 @ Override
312- public Reader asReader (Charset charset ) throws IOException {
319+ public Reader asReader (Charset charset ) {
313320 checkNotNull (charset , "charset should not be null" );
314321 return new InputStreamReader (inputStream , charset );
315322 }
@@ -354,23 +361,23 @@ public boolean isRepeatable() {
354361 }
355362
356363 @ Override
357- public InputStream asInputStream () throws IOException {
364+ public InputStream asInputStream () {
358365 return new ByteArrayInputStream (data );
359366 }
360367
361368 @ SuppressWarnings ("deprecation" )
362369 @ Override
363- public Reader asReader () throws IOException {
370+ public Reader asReader () {
364371 return new InputStreamReader (asInputStream (), UTF_8 );
365372 }
366373
367374 @ Override
368- public Reader asReader (Charset charset ) throws IOException {
375+ public Reader asReader (Charset charset ) {
369376 checkNotNull (charset , "charset should not be null" );
370377 return new InputStreamReader (asInputStream (), charset );
371378 }
372379
373380 @ Override
374- public void close () throws IOException {}
381+ public void close () {}
375382 }
376383}
0 commit comments