/** * Whether the original request received by the synapse is REST * * @param originalInMsgCtx request message * @return <code>true</code> if the request was a REST request */ private static boolean isRequestRest(org.apache.axis2.context.MessageContext originalInMsgCtx) { boolean isRestRequest = originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE) != null; if (!isRestRequest) { String httpMethod = (String) originalInMsgCtx.getProperty( Constants.Configuration.HTTP_METHOD); isRestRequest = Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_PUT.equals(httpMethod) || RESTConstants.METHOD_OPTIONS.equals(httpMethod); if (!isRestRequest) { isRestRequest = Constants.Configuration.HTTP_METHOD_POST.equals(httpMethod) && HTTPTransportUtils.isRESTRequest( String.valueOf(originalInMsgCtx.getProperty( Constants.Configuration.MESSAGE_TYPE))); } } return isRestRequest; }
&& HTTPTransportUtils.isRESTRequest( String.valueOf(originalInMsgCtx.getProperty( Constants.Configuration.MESSAGE_TYPE)));
/** * Whether the original request received by the synapse is REST * * @param originalInMsgCtx request message * @return <code>true</code> if the request was a REST request */ private static boolean isRequestRest(org.apache.axis2.context.MessageContext originalInMsgCtx) { boolean isRestRequest = originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE) != null; if (!isRestRequest) { String httpMethod = (String) originalInMsgCtx.getProperty( Constants.Configuration.HTTP_METHOD); isRestRequest = Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_PUT.equals(httpMethod) || RESTConstants.METHOD_OPTIONS.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_HEAD.equals(httpMethod); if (!isRestRequest) { isRestRequest = Constants.Configuration.HTTP_METHOD_POST.equals(httpMethod) && HTTPTransportUtils.isRESTRequest( String.valueOf(originalInMsgCtx.getProperty( Constants.Configuration.MESSAGE_TYPE))); } } return isRestRequest; }
/** * Whether the original request received by the synapse is REST * * @param originalInMsgCtx request message * @return <code>true</code> if the request was a REST request */ private static boolean isRequestRest(MessageContext originalInMsgCtx) { boolean isRestRequest = originalInMsgCtx.getProperty(NhttpConstants.REST_REQUEST_CONTENT_TYPE) != null; if (!isRestRequest) { String httpMethod = (String) originalInMsgCtx.getProperty( Constants.Configuration.HTTP_METHOD); isRestRequest = Constants.Configuration.HTTP_METHOD_GET.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_DELETE.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_PUT.equals(httpMethod) || RESTConstants.METHOD_OPTIONS.equals(httpMethod) || Constants.Configuration.HTTP_METHOD_HEAD.equals(httpMethod); if (!isRestRequest) { isRestRequest = Constants.Configuration.HTTP_METHOD_POST.equals(httpMethod) && HTTPTransportUtils.isRESTRequest( String.valueOf(originalInMsgCtx.getProperty( Constants.Configuration.MESSAGE_TYPE))); if(!isRestRequest) { isRestRequest = (String.valueOf(originalInMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE)) .equals(HTTPConstants.MEDIA_TYPE_TEXT_XML) && originalInMsgCtx.getSoapAction() == null); } } } return isRestRequest; }
.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) { soapVersion = VERSION_SOAP11; } else if (isRESTRequest(contentType)) {
.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) { soapVersion = VERSION_SOAP11; } else if (isRESTRequest(contentType)) {
/** * */ private void processEntityEnclosingMethod() { try { Header contentType = request.getFirstHeader(HTTP.CONTENT_TYPE); String contentTypeStr = contentType != null ? contentType.getValue() : inferContentType(); String charSetEncoding = BuilderUtil.getCharSetEncoding(contentTypeStr); msgContext.setProperty( Constants.Configuration.CHARACTER_SET_ENCODING, charSetEncoding); if (HTTPTransportUtils.isRESTRequest(contentTypeStr) || isRest(contentTypeStr)) { RESTUtil.processPOSTRequest(msgContext, is, os, request.getRequestLine().getUri(), contentTypeStr, isRestDispatching); } else { Header soapAction = request.getFirstHeader(SOAPACTION); HTTPTransportUtils.processHTTPPostRequest( msgContext, is, os, contentTypeStr, (soapAction != null ? soapAction.getValue() : null), request.getRequestLine().getUri()); } } catch (Exception e) { handleException("Error processing POST request ", e); } }
OutputStream out = response.getOutputStream(); String contentType = request.getContentType(); if (!HTTPTransportUtils.isRESTRequest(contentType)) { msgContext = createMessageContext(request, response); msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
OutputStream out = response.getOutputStream(); String contentType = request.getContentType(); if (!HTTPTransportUtils.isRESTRequest(contentType)) { msgContext = createMessageContext(request, response); msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
if (HTTPTransportUtils.isRESTRequest(contentType)) { pi = RESTUtil.processXMLRequest( msgContext,
if (HTTPTransportUtils.isRESTRequest(contentType)) { pi = RESTUtil.processXMLRequest( msgContext,
msgContext.setProperty(Constants.Configuration.MESSAGE_TYPE, contentType); if (contentTypeHeader == null || HTTPTransportUtils.isRESTRequest(contentTypeHeader) || isRest(contentTypeHeader)) { msgContext.setProperty(PassThroughConstants.REST_REQUEST_CONTENT_TYPE, contentType); msgContext.setDoingREST(true);