mirror of https://github.com/apache/activemq.git
Merge pull request #472 from jbonofre/AMQ-7419
[AMQ-7419] Return 405 error code instead of 500 in case of maxFrameSize exceeded on HTTP connector
This commit is contained in:
commit
46148e3dd1
|
@ -16,17 +16,14 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.transport.http;
|
package org.apache.activemq.transport.http;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import javax.jms.JMSException;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -121,7 +118,13 @@ public class HttpTunnelServlet extends HttpServlet {
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
|
||||||
if (wireFormatOptions.get("maxFrameSize") != null && request.getContentLength() > Integer.parseInt(wireFormatOptions.get("maxFrameSize").toString())) {
|
if (wireFormatOptions.get("maxFrameSize") != null && request.getContentLength() > Integer.parseInt(wireFormatOptions.get("maxFrameSize").toString())) {
|
||||||
throw new ServletException("maxFrameSize exceeded");
|
response.setStatus(405);
|
||||||
|
response.setContentType("plain/text");
|
||||||
|
PrintWriter writer = response.getWriter();
|
||||||
|
writer.println("maxFrameSize exceeded");
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream stream = request.getInputStream();
|
InputStream stream = request.getInputStream();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class HttpMaxFrameSizeTest {
|
||||||
try {
|
try {
|
||||||
send(5000);
|
send(5000);
|
||||||
} catch (JMSException jmsException) {
|
} catch (JMSException jmsException) {
|
||||||
Assert.assertTrue(jmsException.getMessage().contains("500 Server Error"));
|
Assert.assertTrue(jmsException.getMessage().contains("405 Method Not Allowed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue