@@ -18,13 +18,15 @@ public RequestParser(AppConfig appConfig) {
1818 this .contentLength = 0 ;
1919 }
2020
21- public Request parse (InputStream inputStream ) throws IOException {
21+ public Request parse (InputStream inputStream )
22+ throws IOException , IllegalArgumentException {
2223 BufferedReader bufferedReader = new BufferedReader (new InputStreamReader (inputStream ));
2324
2425 RequestLine requestLine = getRequestLine (bufferedReader );
2526
27+ Method method ;
2628 try {
27- Method . valueOf ( requestLine .getMethod () );
29+ method = requestLine .getMethod ();
2830 } catch (IllegalArgumentException e ) {
2931 throw new IllegalArgumentException ();
3032 }
@@ -33,7 +35,7 @@ public Request parse(InputStream inputStream) throws IOException {
3335
3436 String body = getBody (bufferedReader );
3537
36- return new Request (Method . valueOf ( requestLine . getMethod ()) ,
38+ return new Request (method ,
3739 requestLine .getPath (),
3840 headers ,
3941 requestLine .getQueryString (),
@@ -51,8 +53,8 @@ private class RequestLine {
5153 private final String path ;
5254 private final String queryString ;
5355
54- private String getMethod () {
55- return method ;
56+ private Method getMethod () throws IllegalArgumentException {
57+ return Method . valueOf ( method ) ;
5658 }
5759
5860 private String getPath () {
0 commit comments