0

I am using path variable and when i hit the request i get 400 BAD Request

URL : http://localhost:8085/testing/v3/w200/http%3A%2F%2Fwww.bildarchivaustria.at%2FPreview%2F15620341.jpg

I don't know why it's not working. It might be something very simple that i am missing. Please help

Here is my code :


@RestController
@RequestMapping("/testing/v3")
public class ControllerV3 
{
@GetMapping(value = "/{size}/{url}")
    public ResponseEntity<byte[]> testByUrl(
            @PathVariable(name="size", value="size" , required = false) String size,
            @PathVariable("url") String url,
            WebRequest webRequest, HttpServletResponse response) {
        long startTime = 0;
        if (LOG.isDebugEnabled()) {
            startTime = System.nanoTime();
            LOG.debug("url = {}, size = {}", url, size);
        }
// i do other process here and return the image or video
}
}

1 Answers1

1

For security reasons Apache does not allow any %2Fas part of the path (find out more here).

To get the stuff working replace all %2F with %252F in your URL:

http://localhost:8085/testing/v3/w200/http%3A%252F%252Flocalhost%3A8080%252Ftesting%252Fv3%252Fw200%252Fhttp%3A%252F%252Fwww.bildarchivaustria.at%252FPreview%252F15620341.jpg

The encoding of %2F is -> %252F

Patrick
  • 12,336
  • 15
  • 73
  • 115