I am currently working in Spring + JSF + Hibernate project. I have written REST controller in Spring. In the edit profile API, I am recieving the image as a base64 encoded String. The String was initially 73 pages when we copied it in word document but again our android developer compressed it but still it comes around 13 pages. When the API is called with this image, the following exception is thrown
INFO: Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Request header is too large
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I tried googling and came up with 2 solutions, one to increase maxPostSize and the other is to increase the maxHttpHeaderSize. I tried increasing both the values to 5 MB but I still get the exception. How can I solve this? or should I be following some other method to upload images?
The mistake is in the client application, and that's the one which should change. It should send all parameters and values inside request body, not in URL.
In the request body, it can handle image data in two ways:
1) either send image data as a base64 encoded string, but in the body instead of URL
2) or send image data as raw binary data (again in the body, not in URL) . For this, the request should be formed as a multipart request.
The second option is the normal preferred way of doing it.
You need not changing anything in your controller if client goes with the first option above.
You have to make a change only if the android client chooses the second option of sending raw image data (again, this is the recommended way).
If that happens, reply back. I'll explain how to change your spring project to support it.