Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ private static void checkNumberOfParts(Message m, int numberOfParts) {
}

public static boolean isFormPostRequest(Message m) {
return MediaType.APPLICATION_FORM_URLENCODED.equals(m.get(Message.CONTENT_TYPE))
String contentType = (String) m.get(Message.CONTENT_TYPE);
Comment thread
gnodet marked this conversation as resolved.
Outdated
return contentType != null
&& contentType.startsWith(MediaType.APPLICATION_FORM_URLENCODED)
&& HttpMethod.POST.equals(m.get(Message.HTTP_REQUEST_METHOD));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.cxf.Bus;
Expand Down Expand Up @@ -120,7 +119,6 @@ public abstract class AbstractHTTPDestination
protected boolean fixedParameterOrder;
protected boolean multiplexWithAddress;
protected CertConstraints certConstraints;
protected boolean isServlet3;
protected boolean decodeBasicAuthWithIso8859;
protected ContinuationProviderFactory cproviderFactory;
protected boolean enableWebSocket;
Expand All @@ -147,12 +145,6 @@ public AbstractHTTPDestination(Bus b,
this.bus = b;
this.registry = registry;
this.path = path;
try {
ServletRequest.class.getMethod("isAsyncSupported");
isServlet3 = true;
} catch (Throwable t) {
//servlet 2.5 or earlier, no async support
}
decodeBasicAuthWithIso8859 = PropertyUtils.isTrue(bus.getProperty(DECODE_BASIC_AUTH_WITH_ISO8859));

initConfig();
Expand Down Expand Up @@ -513,39 +505,20 @@ private String setEncoding(final Message inMessage,
return contentType;
}
protected Message retrieveFromContinuation(HttpServletRequest req) {
if (!isServlet3) {
if (cproviderFactory != null) {
return cproviderFactory.retrieveFromContinuation(req);
}
return null;
}
return retrieveFromServlet3Async(req);
}

protected Message retrieveFromServlet3Async(HttpServletRequest req) {
try {
return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
} catch (Throwable ex) {
// the request may not implement the Servlet3 API
}
return null;
return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
}

protected void setupContinuation(Message inMessage,
final HttpServletRequest req,
final HttpServletResponse resp) {
try {
if (isServlet3 && req.isAsyncSupported()) {
inMessage.put(ContinuationProvider.class.getName(),
new Servlet3ContinuationProvider(req, resp, inMessage));
} else if (cproviderFactory != null) {
ContinuationProvider p = cproviderFactory.createContinuationProvider(inMessage, req, resp);
if (p != null) {
inMessage.put(ContinuationProvider.class.getName(), p);
}
if (req.isAsyncSupported()) {
inMessage.put(ContinuationProvider.class.getName(),
new Servlet3ContinuationProvider(req, resp, inMessage));
} else if (cproviderFactory != null) {
ContinuationProvider p = cproviderFactory.createContinuationProvider(inMessage, req, resp);
if (p != null) {
inMessage.put(ContinuationProvider.class.getName(), p);
}
} catch (Throwable ex) {
// the request may not implement the Servlet3 API
}
}
protected String getBasePath(String contextPath) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import jakarta.servlet.WriteListener;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.continuations.Continuation;
import org.apache.cxf.continuations.ContinuationCallback;
Expand All @@ -40,18 +39,6 @@
*
*/
public class Servlet3ContinuationProvider implements ContinuationProvider {
static final boolean IS_31;
static {
boolean is31;
try {
ClassLoaderUtils.loadClass("jakarta.servlet.WriteListener", HttpServletRequest.class);
is31 = true;
} catch (Throwable t) {
is31 = false;
}
IS_31 = is31;
}

HttpServletRequest req;
HttpServletResponse resp;
Message inMessage;
Expand Down Expand Up @@ -80,7 +67,7 @@ public Continuation getContinuation() {
}

if (continuation == null) {
continuation = IS_31 ? new Servlet31Continuation() : new Servlet3Continuation();
continuation = new Servlet3Continuation();
Comment thread
gnodet marked this conversation as resolved.
Outdated
} else {
continuation.startAsyncAgain();
}
Expand Down Expand Up @@ -138,7 +125,13 @@ public boolean suspend(long timeout) {
return true;
}
protected void updateMessageForSuspend() {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage.get(WriteListener.class) != null) {
getOutputStream().setWriteListener(currentMessage.get(WriteListener.class));
currentMessage.getInterceptorChain().suspend();
} else {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
}
}
public void redispatch() {
if (!isComplete) {
Expand Down Expand Up @@ -239,7 +232,7 @@ private boolean isClientDisconnected(Throwable ex) {

@Override
public boolean isReadyForWrite() {
return true;
return getOutputStream().isReady();
}

protected ServletOutputStream getOutputStream() {
Expand All @@ -255,26 +248,4 @@ public boolean isTimeout() {
return isTimeout;
}
}
public class Servlet31Continuation extends Servlet3Continuation {
public Servlet31Continuation() {
}

@Override
protected void updateMessageForSuspend() {
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage.get(WriteListener.class) != null) {
// CXF Continuation WriteListener will likely need to be introduced
// for NIO supported with non-Servlet specific mechanisms
getOutputStream().setWriteListener(currentMessage.get(WriteListener.class));
currentMessage.getInterceptorChain().suspend();
} else {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
}
}

@Override
public boolean isReadyForWrite() {
return getOutputStream().isReady();
}
}
}
Loading