55import httpserver .request .Request ;
66import httpserver .file .FileOperator ;
77import httpserver .file .PathExaminer ;
8- import httpserver .response .MethodNotAllowedResponse ;
98import httpserver .response .NotFoundResponse ;
109import httpserver .response .OkResponse ;
1110import httpserver .response .Response ;
@@ -18,17 +17,13 @@ public class PutResponder extends MethodResponder {
1817 private final FileOperator fileOperator ;
1918
2019 public PutResponder (PathExaminer pathExaminer , FileOperator fileOperator ) {
21- super .method = Method .PUT ;
20+ super .method = Method .PUT ;
2221 this .pathExaminer = pathExaminer ;
2322 this .fileOperator = fileOperator ;
2423 }
2524
2625 @ Override
2726 public Response respond (AppConfig appConfig , Request request ) throws IOException {
28- if (!allows (request .getPathString ())) {
29- return new MethodNotAllowedResponse ();
30- }
31-
3227 Path fullPath = pathExaminer .getFullPath (appConfig .getRoot (), request .getPathString ());
3328
3429 if (!pathExaminer .pathExists (fullPath )) {
@@ -39,7 +34,8 @@ public Response respond(AppConfig appConfig, Request request) throws IOException
3934 return new OkResponse (fileOperator .readContents (fullPath ));
4035 }
4136
42- public boolean allows (String pathString ) {
37+ public boolean allows (Request request ) {
38+ String pathString = request .getPathString ();
4339 return pathString .equals ("/form" ) || pathString .equals ("/method_options" );
4440 }
4541}
0 commit comments