Delegate to send the request content.

@param restRequest the Rest request contains the body to be sent
@return a delegate upon invocation sets the request body in reactor-netty outbound object
14065
private static BiFunction<HttpClientRequest, NettyOutbound, Publisher<Void>> bodySendDelegate(final HttpRequest restRequest) {
        BiFunction<HttpClientRequest, NettyOutbound, Publisher<Void>> sendDelegate = (reactorNettyRequest, reactorNettyOutbound) -> {
            for (HttpHeader header : restRequest.headers()) {
                reactorNettyRequest.header(header.name(), header.value());
            }
            if (restRequest.body() != null) {
                Flux<ByteBuf> nettyByteBufFlux = restRequest.body().map(Unpooled::wrappedBuffer);
                return reactorNettyOutbound.send(nettyByteBufFlux);
            } else {
                return reactorNettyOutbound;
            }
        };
        return sendDelegate;
    }
122046
public Nfs3RemoveResponse wrapped_sendRemove(NfsRemoveRequest request) throws IOException {
        RpcResponseHandler<Nfs3RemoveResponse> responseHandler = new NfsResponseHandler<Nfs3RemoveResponse>() {

            /* (non-Javadoc)
             * @see com.emc.ecs.nfsclient.rpc.RpcResponseHandler#makeNewResponse()
             */
            protected Nfs3RemoveResponse makeNewResponse() {
                return new Nfs3RemoveResponse();
            }

        };
        _rpcWrapper.callRpcWrapped(request, responseHandler);
        return responseHandler.getResponse();
    }
331513
public CompletableFuture<CommandResponse> command(CommandRequest request) {
    CompletableFuture<CommandResponse> future = new CompletableFuture<>();
    if (context.isCurrentContext()) {
      sendRequest(request, protocol::command, future);
    } else {
      context.execute(() -> sendRequest(request, protocol::command, future));
    }
    return future;
  }
1270503
private <M extends MessageHeaders<EmptyRequestBody, P, U>, U extends MessageParameters, P extends ResponseBody> CompletableFuture<P>
			sendRequest(M messageHeaders, U messageParameters) {
		return sendRequest(messageHeaders, messageParameters, EmptyRequestBody.getInstance());
	}
978190
public SetDomainLimitRateResponse setDomainLimitRate(SetDomainLimitRateRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("limitRate","");
        this.attachRequestToBody(request, internalRequest);
        return invokeHttpClient(internalRequest, SetDomainLimitRateResponse.class);
    }
164145
protected ApiRequest readRequest(HttpServletRequest request) throws Exception {
        ApiRequestPathInfo pathInfo = getEngine().getApiRequestPathParser().parseEndpoint(request.getPathInfo(), wrapMultiMap(request));//parseApiRequestPath(request);
        if (pathInfo.orgId == null) {
            throw new Exception(Messages.i18n.format("GatewayServlet.InvalidApiEndpoint")); //$NON-NLS-1$
        }
        QueryMap queryParams = parseApiRequestQueryParams(request.getQueryString());

        String apiKey = getApiKey(request, queryParams);

        ApiRequest srequest = GatewayThreadContext.getApiRequest();
        srequest.setApiKey(apiKey);
        srequest.setApiOrgId(pathInfo.orgId);
        srequest.setApiId(pathInfo.apiId);
        srequest.setApiVersion(pathInfo.apiVersion);
        srequest.setUrl(request.getRequestURL().toString());
        srequest.setDestination(pathInfo.resource);
        srequest.setQueryParams(queryParams);
        readHeaders(srequest, request);
        srequest.setRawRequest(request);
        srequest.setRemoteAddr(request.getRemoteAddr());
        srequest.setTransportSecure(request.isSecure());
        return srequest;
    }
439701
public CompletableFuture<BackupResponse> backup(BackupRequest request) {
    ComposableFuture<BackupResponse> future = new ComposableFuture<>();
    threadContext.execute(() -> {
      role.backup(request).whenComplete(future);
    });
    return future;
  }
39396
public static ServletRequest getOuterServletRequest( ServletRequest request )
    {
        ScopedRequest scopedRequest = unwrapRequest( request );
        return scopedRequest != null ? scopedRequest.getOuterRequest() : request;
    }
288121
public Nfs3RenameResponse wrapped_sendRename(NfsRenameRequest request) throws IOException {
        NfsResponseHandler<Nfs3RenameResponse> responseHandler = new NfsResponseHandler<Nfs3RenameResponse>() {

            /* (non-Javadoc)
             * @see com.emc.ecs.nfsclient.rpc.RpcResponseHandler#makeNewResponse()
             */
            protected Nfs3RenameResponse makeNewResponse() {
                return new Nfs3RenameResponse();
            }

        };
        _rpcWrapper.callRpcWrapped(request, responseHandler);
        return responseHandler.getResponse();
    }
1032573
protected void addPortletUrlData(
            final HttpServletRequest request,
            final UrlStringBuilder url,
            final UrlType urlType,
            final IPortletUrlBuilder portletUrlBuilder,
            final IPortletWindowId targetedPortletWindowId,
            final boolean statelessUrl) {

        final IPortletWindowId portletWindowId = portletUrlBuilder.getPortletWindowId();
        final boolean targeted = portletWindowId.equals(targetedPortletWindowId);

        IPortletWindow portletWindow = null;

        // The targeted portlet doesn't need namespaced parameters
        final String prefixedPortletWindowId;
        final String suffixedPortletWindowId;
        // Track whether or not we are adding parameters to the URL for non-targeted or delegate
        // portlets.
        boolean addedNonTargetedPortletParam = false;
        if (targeted) {
            prefixedPortletWindowId = "";
            suffixedPortletWindowId = "";
        } else {
            final String portletWindowIdStr = portletWindowId.toString();
            prefixedPortletWindowId = SEPARATOR + portletWindowIdStr;
            suffixedPortletWindowId = portletWindowIdStr + SEPARATOR;

            // targeted portlets can never be delegates (it is always the top most parent that is
            // targeted)
            portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
            final IPortletWindowId delegationParentId = portletWindow.getDelegationParentId();
            if (delegationParentId != null) {
                url.addParameter(
                        PARAM_DELEGATE_PARENT + prefixedPortletWindowId,
                        delegationParentId.getStringId());
                addedNonTargetedPortletParam = true;
            }
        }

        switch (urlType) {
            case RESOURCE:
                {
                    final String cacheability = portletUrlBuilder.getCacheability();
                    if (cacheability != null) {
                        url.addParameter(
                                PARAM_CACHEABILITY + prefixedPortletWindowId, cacheability);
                        addedNonTargetedPortletParam =
                                !targeted ? true : addedNonTargetedPortletParam;
                    }

                    final String resourceId = portletUrlBuilder.getResourceId();
                    if (!targeted && resourceId != null) {
                        url.addParameter(PARAM_RESOURCE_ID + prefixedPortletWindowId, resourceId);
                        // We know we are !targeted, but kept the assignement consistent with the
                        // other similar
                        // assignments for clarity.
                        addedNonTargetedPortletParam =
                                !targeted ? true : addedNonTargetedPortletParam;
                    }

                    break;
                }
            default:
                {
                    // Add requested portlet mode
                    final PortletMode portletMode = portletUrlBuilder.getPortletMode();
                    if (portletMode != null) {
                        url.addParameter(
                                PARAM_PORTLET_MODE + prefixedPortletWindowId,
                                portletMode.toString());
                        addedNonTargetedPortletParam =
                                !targeted ? true : addedNonTargetedPortletParam;
                    } else if (targeted && statelessUrl) {
                        portletWindow =
                                portletWindow != null
                                        ? portletWindow
                                        : this.portletWindowRegistry.getPortletWindow(
                                                request, portletWindowId);
                        final PortletMode currentPortletMode = portletWindow.getPortletMode();
                        url.addParameter(
                                PARAM_PORTLET_MODE + prefixedPortletWindowId,
                                currentPortletMode.toString());
                        // We know we are targeted, but kept the assignement consistent with the
                        // other similar
                        // assignments for clarity. Will always be a nop.
                        addedNonTargetedPortletParam =
                                !targeted ? true : addedNonTargetedPortletParam;
                    }

                    // Add requested window state if it isn't included on the path
                    final WindowState windowState = portletUrlBuilder.getWindowState();
                    if (windowState != null
                            && (!targeted || !PATH_WINDOW_STATES.contains(windowState))) {
                        url.addParameter(
                                PARAM_WINDOW_STATE + prefixedPortletWindowId,
                                windowState.toString());
                        addedNonTargetedPortletParam =
                                !targeted ? true : addedNonTargetedPortletParam;
                    }

                    break;
                }
        }

        if (portletUrlBuilder.getCopyCurrentRenderParameters()) {
            url.addParameter(PARAM_COPY_PARAMETERS + suffixedPortletWindowId);
            addedNonTargetedPortletParam = !targeted ? true : addedNonTargetedPortletParam;
        }

        final Map<String, String[]> parameters = portletUrlBuilder.getParameters();
        if (!parameters.isEmpty()) {
            url.addParametersArray(PORTLET_PARAM_PREFIX + suffixedPortletWindowId, parameters);
            addedNonTargetedPortletParam = !targeted ? true : addedNonTargetedPortletParam;
        }

        // UP-4566 If we have added a portlet parameter for a non-targeted (or delegate) portlet add
        // in the
        // additional-portlet parameter to aid in URL parsing later on.  Among other things the
        // practical impact
        // of this is when we do a search which sends an event to all porlets the user has access to
        // which adds a
        // bunch of portletUrlBuilders to the request, we don't add a bunch of unnecessary &PCa
        // parameters to the
        // URL since there are no parameters actually being passed to the searched portlets.
        if (addedNonTargetedPortletParam) {
            url.addParameter(PARAM_ADDITIONAL_PORTLET, portletWindowId.toString());
        }
    }
652598
public int sendRequest(final String methodName,
                         final String url,
                         final List<Header> hdrs,
                         final String contentType, final int contentLen,
                         final byte[] content) throws HttpException {
    int sz = 0;
    if (content != null) {
      sz = content.length;
    }

    if (debug()) {
      debug("About to send request: method=" + methodName +
                    " url=" + url +
                    " contentLen=" + contentLen +
                    " content.length=" + sz +
                    " contentType=" + contentType);
    }

    try {
      URI u = new URI(url);

      if (!hostSpecified && (u.getHost() == null)) {
        if ((baseURI == null) && (baseURIValue != null)) {
          baseURI = new URI(baseURIValue);
        }

        if (baseURI == null) {
          throw new HttpException("No base URI specified for non-absolute URI " + url);
        }

        if (baseURI.getHost() == null) {
          throw new HttpException("Base URI must be absolute: " + baseURI);
        }

        u = baseURI.resolve(u);
      }

      if (debug()) {
        debug("      url resolves to " + u);
      }

      method = findMethod(methodName, u);

      if (credentials != null) {
        getCredentialsProvider().setCredentials(new AuthScope(u.getHost(),
                                                              u.getPort()),
                                                credentials);
      }

      if (!Util.isEmpty(hdrs)) {
        for (final Header hdr: hdrs) {
          method.addHeader(hdr);
        }
      }

      if (method instanceof HttpEntityEnclosingRequestBase) {
        if (content != null) {
          if (contentType == null) {
            setContent(content, "text/xml");
          } else {
            setContent(content, contentType);
          }
        }
      }

      response = execute(method);
    } catch (final HttpException he) {
      throw he;
    } catch (final Throwable t) {
      throw new HttpException(t.getLocalizedMessage(), t);
    }
    status = response.getStatusLine().getStatusCode();

    return status;
  }
1024398
public ClientTransaction sendRequest(Request request) throws SipException, TransactionUnavailableException {
		ensureCorrectDialogLocalTag(request);
		final ClientTransactionWrapper ctw = ra.getProviderWrapper().getNewDialogActivityClientTransaction(this,request);
		if (request.getMethod().equals(Request.INVITE))
			lastCancelableTransactionId = ctw.getActivityHandle();
		if (tracer.isInfoEnabled()) {
			tracer.info(String.valueOf(ctw)+" sending request:\n"+request);
		}
		wrappedDialog.sendRequest(ctw.getWrappedClientTransaction());				
		return ctw;
	}
928472
@Override
	public void handleRequest(final Request request) {
		if (!isInitialised()) {
			getOrCreateComponentModel().delegate = new SafetyContainerDelegate(UIContextHolder.
					getCurrent());
			setInitialised(true);
		}

		try {
			UIContext delegate = getComponentModel().delegate;
			UIContextHolder.pushContext(delegate);

			try {
				for (int i = 0; i < shim.getChildCount(); i++) {
					shim.getChildAt(i).serviceRequest(request);
				}

				delegate.doInvokeLaters();
			} finally {
				UIContextHolder.popContext();
			}
		} catch (final ActionEscape e) {
			// We don't want to catch ActionEscapes (e.g. ForwardExceptions)
			throw e;
		} catch (final Exception e) {
			if (isAjaxOrTargetedRequest(request)) {
				throw new SystemException(e.getMessage(), e);
			} else {
				setAttribute(ERROR_KEY, e);
			}
		}
	}
1095471
@Override
	protected String sendGetRequest(HttpRequest httpRequest) throws AbstractCosException {
		String url = httpRequest.getUrl();
		HttpGet httpGet = null;
		String responseStr = "";
		int retry = 0;
		int maxRetryCount = this.config.getMaxFailedRetry();
		while (retry < maxRetryCount) {
			try {
				URIBuilder urlBuilder = new URIBuilder(url);
				for (String paramKey : httpRequest.getParams().keySet()) {
					urlBuilder.addParameter(paramKey, httpRequest.getParams().get(paramKey));
				}
				httpGet = new HttpGet(urlBuilder.build());
			} catch (URISyntaxException e) {
				String errMsg = "Invalid url:" + url;
				LOG.error(errMsg);
				throw new ParamException(errMsg);
			}

			httpGet.setConfig(requestConfig);
			setHeaders(httpGet, httpRequest.getHeaders());

			try {
				HttpResponse httpResponse = httpClient.execute(httpGet);
				;
				int responseStatusCode = httpResponse.getStatusLine().getStatusCode();
				if (responseStatusCode == 200 || responseStatusCode == 400) {
					responseStr = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
					return responseStr;
				} else {
					String errMsg = getErrorHttpResponseMsg(httpRequest, httpResponse.getStatusLine());
					throw new NetworkException(errMsg);
				}
			} catch (ParseException | IOException e) {
				++retry;
				if (retry == maxRetryCount) {
					String errMsg = getExceptionMsg(httpRequest, e.toString());
					throw new ServerException(errMsg);
				}
			} finally {
				httpGet.releaseConnection();
			}
		}
		return responseStr;

	}
1027194
public static void bind(HttpServletRequest request) {
        if (request != null && threadLocal.get() != null) {
            throw new IllegalStateException("HttpServletRequestHolder.bind() called for a "
                    + "thread that already has a request associated with it. It's likely that the request "
                    + "was not correctly removed from the thread before it is put back into the thread pool.");
        }
        threadLocal.set(request);
    }
514235
@SuppressWarnings("null")
  public static @Nullable Page getContentPage(@NotNull HttpServletRequest request) {
    SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request;
    Resource contentResource = getContentResourceOrParent(request);
    if (contentResource != null) {
      PageManager pageManager = slingRequest.getResourceResolver().adaptTo(PageManager.class);
      return pageManager.getContainingPage(contentResource);
    }
    else {
      return null;
    }
  }
479795
public Nfs3MknodResponse wrapped_sendMknod(NfsMknodRequest request) throws IOException {
        RpcResponseHandler<Nfs3MknodResponse> responseHandler = new NfsResponseHandler<Nfs3MknodResponse>() {
            
            /* (non-Javadoc)
             * @see com.emc.ecs.nfsclient.rpc.RpcResponseHandler#makeNewResponse()
             */
            protected Nfs3MknodResponse makeNewResponse() {
                return new Nfs3MknodResponse();
            }

        };
        _rpcWrapper.callRpcWrapped(request, responseHandler);
        return responseHandler.getResponse();
    }