Processes a request body and puts it in a format compatible with
the "request" library.

@todo: Move this to the SDK.
@param request - Request object
@param protocolProfileBehavior - Protocol profile behaviors

@returns {Object}
775849
function (request, protocolProfileBehavior) {
        if (!(request && request.body)) {
            return;
        }

        var requestBody = request.body,
            requestBodyType = requestBody.mode,
            requestMethod = (typeof request.method === 'string') ? request.method.toLowerCase() : undefined,
            bodyIsEmpty = requestBody.isEmpty(),
            bodyIsDisabled = requestBody.disabled,
            bodyContent = requestBody[requestBodyType],

            // flag to decide body pruning for METHODS_WITHOUT_BODY
            // @note this will be `true` even if protocolProfileBehavior is undefined
            pruneBody = protocolProfileBehavior ? !protocolProfileBehavior.disableBodyPruning : true;

        // early bailout for empty or disabled body (this area has some legacy shenanigans)
        if (bodyIsEmpty || bodyIsDisabled) {
            return;
        }

        // bail out if request method doesn't support body and pruneBody is true.
        if (METHODS_WITHOUT_BODY[requestMethod] && pruneBody) {
            return;
        }

        // even if body is not empty, but the body type is not known, we do not know how to parse the same
        //
        // @note if you'd like to support additional body types beyond formdata, url-encoding, etc, add the same to
        //       the builder module
        if (!requestBodyBuilders.hasOwnProperty(requestBodyType)) {
            return;
        }

        return requestBodyBuilders[requestBodyType](bodyContent, request);
    }
1144661
function(url, processRes){
                var self = this;

                //iterators
                var key, header;

                var method      = data.method || 'get';
                var async       = data.sync !== true;
                var request     = new XMLHttpRequest();
                var _data       = data.data;
                var body        = data.body;
                var contentType = this.header('Content-Type');
                var timeout     = data.timeout;
                var timeoutId;
                var isUrlEncoded;
                var openParams;

                //guess content type
                if(!contentType && _data && _dataInBody()){
                    this.header('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
                    contentType = this.header('Content-Type');
                }

                //if data is used in body, it needs some modifications regarding the content type
                if(_data && _dataInBody()){
                    if(typeof body !== 'string'){
                        body = '';
                    }

                    if(contentType.indexOf('json') > -1){
                        try {
                            body = JSON.stringify(_data);
                        } catch(e){
                            throw new TypeError('Unable to stringify body\'s content : ' + e.name);
                        }
                    } else {
                        isUrlEncoded = contentType && contentType.indexOf('x-www-form-urlencoded') > 1;
                        for(key in _data){
                            if(isUrlEncoded){
                                body += encodeURIComponent(key) + '=' + encodeURIComponent(_data[key]) + '&';
                            } else {
                                body += key + '=' + _data[key] + '\n\r';
                            }
                        }
                    }
                }

                //open the XHR request
                openParams = [method, url, async];
                if(data.auth){
                    openParams.push(data.auth.user);
                    openParams.push(data.auth.passwd);
                }
                request.open.apply(request, openParams);

                //set the headers
                for(header in data.headers){
                    request.setRequestHeader(header, data.headers[header]);
                }

                //bind events
                request.onprogress = function(e){
                    if (e.lengthComputable) {
                        self.trigger('progress', e.loaded / e.total);
                    }
                };

                request.onload = function onRequestLoad(){
                    var response = request.responseText;

                    if (timeoutId) {
                        clearTimeout(timeoutId);
                    }
                    if(this.status >= 200 && this.status < 300){
                        if(typeof processRes === 'function'){
                            response = processRes(response);
                        }
                        self.trigger('success', response);
                    }

                    self.trigger(this.status, response);

                    self.trigger('end', response);
                };

                request.onerror = function onRequestError (err){
                    if (timeoutId) {
                        clearTimeout(timeoutId);
                    }
                    self.trigger('error', err, arguments);
                };

                //sets the timeout
                if (timeout) {
                    timeoutId = setTimeout(function() {
                        self.trigger('timeout', {
                            type: 'timeout',
                            expiredAfter: timeout
                        }, request, arguments);
                        request.abort();
                    }, timeout);
                }

                //send the request
                request.send(body);
            }
991713
@GetMapping(path = SamlIdPConstants.ENDPOINT_SAML2_SSO_PROFILE_POST_SIMPLE_SIGN)
    protected void handleSaml2ProfileSsoRedirectRequest(final HttpServletResponse response,
                                                        final HttpServletRequest request) throws Exception {
        val decoder = getSamlProfileHandlerConfigurationContext().getSamlMessageDecoders().getInstance(HttpMethod.GET);
        handleSsoPostProfileRequest(response, request, decoder);
    }
1043663
public Object invoke(String request, Map<String,String> metaInfo) {
        try {
            Map<String,Object> headers = new HashMap<String,Object>();
            if (metaInfo != null) {
                for (String name : metaInfo.keySet())
                    headers.put(name, metaInfo.get(name));
            }
            Exchange exchange = prepareCamelExchange(request, headers);
            getProcessor().process(exchange);
            return exchange.getOut().getBody(String.class);
        }
        catch (Exception ex) {
            logger.severeException(ex.getMessage(), ex);

            // build the response as a string for now as this is fastest
            if (request == null || request.isEmpty() || ListenerHelper.isJson(request)) {
                return jsonResponse(ex);
            }
            else {
                return xmlResponse(ex);
            }
        }
    }
561009
public static base_response add(nitro_service client, nshttpprofile resource) throws Exception {
		nshttpprofile addresource = new nshttpprofile();
		addresource.name = resource.name;
		addresource.dropinvalreqs = resource.dropinvalreqs;
		addresource.markhttp09inval = resource.markhttp09inval;
		addresource.markconnreqinval = resource.markconnreqinval;
		addresource.cmponpush = resource.cmponpush;
		addresource.conmultiplex = resource.conmultiplex;
		addresource.maxreusepool = resource.maxreusepool;
		addresource.dropextracrlf = resource.dropextracrlf;
		addresource.incomphdrdelay = resource.incomphdrdelay;
		addresource.websocket = resource.websocket;
		addresource.reqtimeout = resource.reqtimeout;
		addresource.adpttimeout = resource.adpttimeout;
		addresource.reqtimeoutaction = resource.reqtimeoutaction;
		addresource.dropextradata = resource.dropextradata;
		addresource.weblog = resource.weblog;
		addresource.clientiphdrexpr = resource.clientiphdrexpr;
		addresource.maxreq = resource.maxreq;
		addresource.persistentetag = resource.persistentetag;
		addresource.spdy = resource.spdy;
		return addresource.add_resource(client);
	}
272540
function delegate(client, fn) {
  // Add this function to the current client
  // and wrap with a connection check
  client[fn] = function(...args) {
    let self = this;
    let p = null;
    if (sand.profiler && sand.profiler.enabled) {
      // Build the profiler request
      let req = `riak ${fn} `;
      if (args[0].bucketType) {
        req += `types/${args[0].bucketType} `;
      }

      if (args[0].bucket) {
        req += `bucket/${args[0].bucket} `;
      }

      if (args[0].indexName) {
        req += `search/${args[0].indexName} `;
      }

      if (args[0].q) {
        req += `query/${args[0].q.replace(/(\w+):\w+/ig, '$1:*')}`
      }

      p = sand.profiler.profile(req.trim());
    }

    return new Promise(function(resolve, reject) {

      function returnResult(err, response, data) {
        p && p.stop();
        if (err) {
          err = new Error(err);
          err.data = data;
          err.req = `${fn}: ${args[0]}`;
          sand.riak.error(`${err.message} ${fn}:`, ...args);
          return reject(err);
        }

        resolve(response);
      }

      client.client[fn](...args, returnResult);
    }).catch(sand.error);
  };
}
1233012
@Override
  public Answer processRequest(IRequest request, IRealm matchedRealm) {
    try {
      Answer ans = request.createAnswer(RESULT_REDIRECT_INDICATION);
      AvpSet set = ans.getAvps();
      String[] destHosts = matchedRealm.getPeerNames();
      for (String host:destHosts) {
        set.addAvp(Avp.REDIRECT_HOST, host, false);
      }

      IAgentConfiguration agentConfiguration = matchedRealm.getAgentConfiguration();
      //default
      int rhuValue = RHU_REALM_AND_APPLICATION;
      if (agentConfiguration != null) {
        Properties p = agentConfiguration.getProperties();
        try {
          rhuValue = Integer.parseInt(p.getProperty(RHU_PROPERTY, "" + rhuValue));
        }
        catch (Exception e) {
          if (logger.isWarnEnabled()) {
            logger.warn("Failed to parse configuration value. ", e);
          }
        }
      }

      set.addAvp(Avp.REDIRECT_HOST_USAGE, rhuValue);
      ans.setError(true);
      super.container.sendMessage((IMessage) ans);
    }
    catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug("Failure when trying to send Answer", e);
      }
      Answer ans = request.createAnswer(RESULT_INVALID_AVP_VALUE);
      // now lets do the magic.
      if (e instanceof AvpDataException && ((AvpDataException) e).getAvp() != null) {
        // lets add failed if its present
        AvpSet failedAvp = ans.getAvps().addGroupedAvp(Avp.FAILED_AVP);
        failedAvp.addAvp(((AvpDataException) e).getAvp());
      }
      try {
        container.sendMessage((IMessage) ans);
      }
      catch (RouteException re) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", re);
        }
      }
      catch (AvpDataException ade) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", ade);
        }
      }
      catch (IllegalDiameterStateException idse) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", idse);
        }
      }
      catch (IOException ioe) {
        if (logger.isDebugEnabled()) {
          logger.debug("Failure when trying to send failure answer", ioe);
        }
      }
    }
    return null;
  }
34457
@RequestMapping(value = "/api/profile", method = RequestMethod.POST)
    public
    @ResponseBody
    HashMap<String, Object> addProfile(Model model, String name) throws Exception {
        logger.info("Should be adding the profile name when I hit the enter button={}", name);
        return Utils.getJQGridJSON(profileService.add(name), "profile");
    }
1280966
function parseProfile (options) {
    var staticOptions = options.static
    var dynamicOptions = options.dynamic

    var profileEnable
    if (S_PROFILE in staticOptions) {
      var value = !!staticOptions[S_PROFILE]
      profileEnable = createStaticDecl(function (env, scope) {
        return value
      })
      profileEnable.enable = value
    } else if (S_PROFILE in dynamicOptions) {
      var dyn = dynamicOptions[S_PROFILE]
      profileEnable = createDynamicDecl(dyn, function (env, scope) {
        return env.invoke(scope, dyn)
      })
    }

    return profileEnable
  }
676727
@Override
  public void doPushProfileAnswer(ServerCxDxSession appSession, JPushProfileRequest request, JPushProfileAnswer answer)
      throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {
    logger.info("Diameter Cx/Dx Session Factory :: doPushProfileAnswer :: appSession[{}], Request[{}], Answer[{}]", new Object[]{appSession, request, answer});
  }
1316836
public MicroProfileJwtTaiRequest createMicroProfileJwtTaiRequestAndSetRequestAttribute(HttpServletRequest request) {
        String methodName = "createMicroProfileJwtTaiRequestAndSetRequestAttribute";
        if (tc.isDebugEnabled()) {
            Tr.entry(tc, methodName, request);
        }
        MicroProfileJwtTaiRequest mpJwtTaiRequest = new MicroProfileJwtTaiRequest(request);
        request.setAttribute(ATTRIBUTE_TAI_REQUEST, mpJwtTaiRequest);
        if (tc.isDebugEnabled()) {
            Tr.exit(tc, methodName, mpJwtTaiRequest);
        }
        return mpJwtTaiRequest;
    }
425681
def createProfile(self, profile=None, clearLayout=True):
        
        if profile:
            prof = profile
        elif not self.viewWidget() or clearLayout:
            prof = XViewProfile()
        else:
            prof = self.viewWidget().saveProfile()
        
        blocked = self.signalsBlocked()
        self.blockSignals(False)
        changed = self.editProfile(prof)
        self.blockSignals(blocked)
        
        if not changed:
            return
        
        act = self.addProfile(prof)
        act.setChecked(True)
        
        # update the interface
        if self.viewWidget() and (profile or clearLayout):
            self.viewWidget().restoreProfile(prof)
        
        if not self.signalsBlocked():
            self.profileCreated.emit(prof)
            self.profilesChanged.emit()
674249
private static String checkProfilePicturePath(
			final FormItemList formItemList,
			final CreateUserResponse createUserResponse) {
		final String profilePicturePath = formItemList
				.getField(ProtocolConstants.Parameters.Create.User.PROFILE_PICTURE_PATH);
		if (profilePicturePath != null) {
			return profilePicturePath;
		} else {
			createUserResponse.profilePicturePathMissing();
		}

		return null;
	}
877872
@Override
	public void serviceRequest(final Request request) {

		// Get expected step count
		UIContext uic = UIContextHolder.getCurrent();
		int expected = uic.getEnvironment().getStep();

		// Get step count from the request
		int got = StepCountUtil.getRequestStep(request);

		// Match (first time, both are zero)
		// or no Step count and processing a GET
		if (expected == got || (!StepCountUtil.isStepOnRequest(request) && "GET".equals(request.
				getMethod()))) {
			// Process Service Request
			getBackingComponent().serviceRequest(request);
		} else { // Invalid step
			LOG.warn(
					"SERVER: Wrong step detected. Expected step " + expected + " but got step " + got);

			// Redirect to error page
			if (StepCountUtil.isErrorRedirect()) {
				String url = StepCountUtil.getErrorUrl();
				LOG.warn("User will be redirected to an error page. URL: " + url);
				try {
					getResponse().sendRedirect(url);
				} catch (IOException e) {
					LOG.warn("Error trying to redirect for wrong step indicator.");
				}

				// Make sure the render phase is not processed
				throw new ActionEscape();
			} else {  // Warp to the future
				// Call handle step error
				WComponent application = getUI();
				if (application instanceof WApplication) {
					LOG.warn("The handleStepError method will be called on WApplication.");
					((WApplication) application).handleStepError();
				}

				LOG.warn("The render phase will warp the user back to the future.");
			}
		}
	}
966431
@Override
    public boolean processParameters(HttpServletRequest request, HttpServletResponse response) {
        final IPortalRequestInfo portalRequestInfo =
                this.urlSyntaxProvider.getPortalRequestInfo(request);

        final IPortletWindowId targetedPortletWindowId =
                portalRequestInfo.getTargetedPortletWindowId();

        for (final IPortletRequestInfo portletRequestInfo :
                portalRequestInfo.getPortletRequestInfoMap().values()) {
            final IPortletWindowId portletWindowId = portletRequestInfo.getPortletWindowId();
            final IPortletWindow portletWindow =
                    this.portletWindowRegistry.getPortletWindow(request, targetedPortletWindowId);

            final UrlType urlType = portalRequestInfo.getUrlType();
            switch (urlType) {
                case RENDER:
                    {
                        final Map<String, List<String>> portletParameters =
                                portletRequestInfo.getPortletParameters();
                        portletWindow.setRenderParameters(
                                ParameterMap.convertListMap(portletParameters));

                        // fall through, render uses state/mode info
                    }
                case ACTION:
                    {
                        final WindowState windowState = portletRequestInfo.getWindowState();
                        if (windowState != null) {
                            portletWindow.setWindowState(windowState);
                        }

                        final PortletMode portletMode = portletRequestInfo.getPortletMode();
                        if (portletMode != null) {
                            portletWindow.setPortletMode(portletMode);
                        }

                        break;
                    }

                default:
                    // Do nothing
            }

            // Override the window state of the targeted portlet window based on the url state
            if (portletWindowId.equals(targetedPortletWindowId)) {
                final UrlState urlState = portalRequestInfo.getUrlState();
                switch (urlState) {
                    case MAX:
                        {
                            portletWindow.setWindowState(WindowState.MAXIMIZED);
                            break;
                        }
                    case DETACHED:
                        {
                            portletWindow.setWindowState(IPortletRenderer.DETACHED);
                            break;
                        }
                    case EXCLUSIVE:
                        {
                            portletWindow.setWindowState(IPortletRenderer.EXCLUSIVE);
                            break;
                        }
                    default:
                        // Do nothing
                }
            }

            this.portletWindowRegistry.storePortletWindow(request, portletWindow);
        }

        return true;
    }
1298909
protected function doRequestInProcess($request)
    {
        $response = parent::doRequestInProcess($request);

        $this->profiler = false;

        return $response;
    }
1215957
public JSONObject processAPIRequest(
			String urlString,
			JSONObject request,
			String requestType, 
			String[] requestParameters,
			String... requestHedaers) throws CertificateException, IOException, JSONException {
		resetRequestScenarioVariables();
		
		String response = null;
		
		GenericUser authenticationUser = (GenericUser) getScenarioGlobals().getAttribute(API_AUTHENTICATION_USER);
		
		if(BROWSER_API_ACCESS_MODE.equals(getAPIAccessMode())) {
			response = processBrowserAPIRequest(urlString, request, requestType, requestParameters);
		}
		else {
			response = processHTTPAPIRequest(urlString, request, authenticationUser, requestType, requestParameters, requestHedaers);			
		}
		
		JSONObject responseJSON = null;
		
		try{
			if(!StringUtils.isBlank(response)) {
				responseJSON = new JSONObject(response);
				log.debug("API JSON response: " + responseJSON.toString(4));
			}				
		}
		catch(JSONException ex) {
			fail("Contructing the JSON respose failed with: " + ex.getLocalizedMessage() + "\n\nResponse: " + response);
		}
		getScenarioGlobals().setAttribute(APIAccessService.LAST_SCENARIO_JSON_RESPONSE_KEY, responseJSON);
		return responseJSON;
	}