Skip to content

Commit 8d62eb4

Browse files
AXIS2-5971 AxisServlet.processURLRequest uses content-type header instead of accept
1 parent 88b56cd commit 8d62eb4

File tree

1 file changed

+11
-2
lines changed
  • modules/transport/http/src/main/java/org/apache/axis2/transport/http

1 file changed

+11
-2
lines changed

modules/transport/http/src/main/java/org/apache/axis2/transport/http/AxisServlet.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import jakarta.servlet.http.HttpServlet;
6363
import jakarta.servlet.http.HttpServletRequest;
6464
import jakarta.servlet.http.HttpServletResponse;
65+
import jakarta.ws.rs.core.HttpHeaders;
6566
import javax.xml.namespace.QName;
6667
import java.io.BufferedInputStream;
6768
import java.io.BufferedOutputStream;
@@ -897,8 +898,16 @@ public void processXMLRequest() throws IOException, ServletException {
897898

898899
public void processURLRequest() throws IOException, ServletException {
899900
try {
900-
RESTUtil.processURLRequest(messageContext, response.getOutputStream(),
901-
request.getContentType());
901+
// AXIS2-5971, content-type is not present on some
902+
// types of REST requests that have no body and in
903+
// those cases use the 'accept' header if defined
904+
final String accept = request.getHeader(HttpHeaders.ACCEPT);
905+
final String contentType = request.getContentType();
906+
if (contentType == null && accept != null) {
907+
RESTUtil.processURLRequest(messageContext, response.getOutputStream(), accept);
908+
} else {
909+
RESTUtil.processURLRequest(messageContext, response.getOutputStream(), contentType);
910+
}
902911
this.checkResponseWritten();
903912
} catch (AxisFault e) {
904913
setResponseState(messageContext, response);

0 commit comments

Comments
 (0)