/*
(non-Javadoc)

@see
mtas.solr.handler.component.util.MtasSolrComponent#modifyRequest(org.apache
.solr.handler.component.ResponseBuilder,
org.apache.solr.handler.component.SearchComponent,
org.apache.solr.handler.component.ShardRequest)
3628
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
      ShardRequest sreq) {
    if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
        && sreq.params.getBool(PARAM_MTAS_LIST, false)) {
      // compute keys
      Set<String> keys = MtasSolrResultUtil
          .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_LIST);
      if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
        for (String key : keys) {
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_PREFIX);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_START);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_LEFT);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_RIGHT);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_OUTPUT);
          // don't get data
          sreq.params.add(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER, "0");
        }
      } else {
        sreq.params.remove(PARAM_MTAS_LIST);
        for (String key : keys) {
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_FIELD);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_VALUE);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_TYPE);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_PREFIX);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_QUERY_IGNORE);
          sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."
              + NAME_MTAS_LIST_QUERY_MAXIMUM_IGNORE_LENGTH);
          Set<String> subKeys = MtasSolrResultUtil
              .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_LIST + "."
                  + key + "." + NAME_MTAS_LIST_QUERY_VARIABLE);
          for (String subKey : subKeys) {
            sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."
                + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subKey + "."
                + SUBNAME_MTAS_LIST_QUERY_VARIABLE_NAME);
            sreq.params.remove(PARAM_MTAS_LIST + "." + key + "."
                + NAME_MTAS_LIST_QUERY_VARIABLE + "." + subKey + "."
                + SUBNAME_MTAS_LIST_QUERY_VARIABLE_VALUE);
          }
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_KEY);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_PREFIX);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_START);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_NUMBER);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_LEFT);
          sreq.params
              .remove(PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_RIGHT);
          sreq.params.remove(
              PARAM_MTAS_LIST + "." + key + "." + NAME_MTAS_LIST_OUTPUT);
        }
      }
    }
  }
131856
@Override
  public void modifyRequest(ResponseBuilder rb, SearchComponent who,
      ShardRequest sreq) {
    sreq.params.remove(PARAM_MTAS_STATUS + "." + NAME_MTAS_STATUS_KEY);
  }
511158
public void setRequest(ServletRequest request) {
        if (request != null) {
            if (logger.isDebugEnabled()) {
                logger.debug(String.format("set request: %s", request));
            }
            this.threadLocalRequests.set((HttpServletRequest) request);
        } else {
            //if null, remove from threadLocalRequests
            // @see WindowTask#run 's finally
            if (logger.isDebugEnabled()) {
                HttpServletRequest tmpRequest = this.threadLocalRequests.get();
                logger.debug(String.format("remove request: %s", tmpRequest));
            }
            this.threadLocalRequests.remove();
        }
    }
508047
public void addRequest(RecordRequest request) {
        if (request.getRequestSize() + getRequestSize() > 248) {
            throw new IllegalArgumentException();
        }

        if (records == null) {
            records = new RecordRequest[1];
        }
        else {
            RecordRequest old[] = records;
            records = new RecordRequest[old.length + 1];

            System.arraycopy(old, 0, records, 0, old.length);
        }
        records[records.length - 1] = request;

        setDataLength(getRequestSize());
    }
1348574
private void addQueryParams(final Request request) {
        if (absoluteDateCreated != null) {
            request.addQueryParam("DateCreated", absoluteDateCreated.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeDateCreated != null) {
            request.addQueryDateRange("DateCreated", rangeDateCreated);
        }

        if (absoluteDateUpdated != null) {
            request.addQueryParam("DateUpdated", absoluteDateUpdated.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeDateUpdated != null) {
            request.addQueryDateRange("DateUpdated", rangeDateUpdated);
        }

        if (friendlyName != null) {
            request.addQueryParam("FriendlyName", friendlyName);
        }

        if (status != null) {
            request.addQueryParam("Status", status.toString());
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
1104141
@Override
	public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
		sec.getUserProperties().put(Constants.HANDSHAKEREQUEST, request);
		super.modifyHandshake(sec, request, response);
	}
763162
@Override
    protected void sideEffectRequestToCancel(final BinaryRequest request) {
        super.sideEffectRequestToCancel(request);

        if (request instanceof BinaryStoreRequest) {
            ((BinaryStoreRequest) request).content().release();
        } else if (request instanceof AppendRequest) {
            ((AppendRequest) request).content().release();
        } else if (request instanceof PrependRequest) {
            ((PrependRequest) request).content().release();
        }
    }
465172
public void modifyRequest(ResponseBuilder rb, SearchComponent who,
      ShardRequest sreq) {
    // System.out.println(
    // "collection: " + System.nanoTime() + " - " +
    // Thread.currentThread().getId()
    // + " - " + rb.req.getParams().getBool("isShard", false)
    // + " MODIFYREQUEST " + rb.stage + " " + rb.req.getParamString());
    if (sreq.params.getBool(MtasSolrSearchComponent.PARAM_MTAS, false)
        && sreq.params.getBool(PARAM_MTAS_COLLECTION, false)) {
      if ((sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) != 0) {
        // do nothing
      } else {
        // remove for other requests
        Set<String> keys = MtasSolrResultUtil
            .getIdsFromParameters(rb.req.getParams(), PARAM_MTAS_COLLECTION);
        sreq.params.remove(PARAM_MTAS_COLLECTION);
        for (String key : keys) {
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_ACTION);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_ID);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_FIELD);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_POST);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_KEY);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_URL);
          sreq.params.remove(PARAM_MTAS_COLLECTION + "." + key + "."
              + NAME_MTAS_COLLECTION_COLLECTION);
        }
      }
    }
  }
1019454
private void addQueryParams(final Request request) {
        if (status != null) {
            request.addQueryParam("Status", status);
        }

        if (iccid != null) {
            request.addQueryParam("Iccid", iccid);
        }

        if (ratePlan != null) {
            request.addQueryParam("RatePlan", ratePlan);
        }

        if (eId != null) {
            request.addQueryParam("EId", eId);
        }

        if (simRegistrationCode != null) {
            request.addQueryParam("SimRegistrationCode", simRegistrationCode);
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
1294971
public static void updateDirectEditFlagInSession(ServletRequest request) {

        String disabledParam = request.getParameter(CmsGwtConstants.PARAM_DISABLE_DIRECT_EDIT);
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(disabledParam)) {
            if (Boolean.parseBoolean(disabledParam)) {
                ((HttpServletRequest)request).getSession().setAttribute(
                    CmsGwtConstants.PARAM_DISABLE_DIRECT_EDIT,
                    Boolean.TRUE);
                String buttonLeft = request.getParameter(CmsGwtConstants.PARAM_BUTTON_LEFT);
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(buttonLeft)) {
                    Integer left = null;
                    try {
                        left = Integer.valueOf(buttonLeft);
                        if (left.intValue() > 0) {
                            ((HttpServletRequest)request).getSession().setAttribute(
                                CmsGwtConstants.PARAM_BUTTON_LEFT,
                                left);
                        }
                    } catch (NumberFormatException e) {
                        // malformed parameter, ignore
                    }
                }
            } else {
                ((HttpServletRequest)request).getSession().removeAttribute(CmsGwtConstants.PARAM_DISABLE_DIRECT_EDIT);
            }
        }
    }
415333
@Override
    public void handleRequest(HttpInboundConnection hic, HttpServletRequest request, HttpServletResponse response) {
        Http2InboundConnection h2ic = (Http2InboundConnection) hic;
        H2UpgradeHandlerWrapper h2uh = null;
        try {
            h2uh = request.upgrade(H2UpgradeHandlerWrapper.class);
        } catch (IOException e) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "returning: user configurator threw an IOException. Exception message: " + e.getMessage());
            }
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;

        } catch (ServletException e) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "returning: user configurator threw a ServletException. Exception message: " + e.getMessage());
            }
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }
        if (h2uh != null) {
            h2uh.init(new H2UpgradeHandler());
        }
        
        // create a map of the headers to pass to the transport code
        Map<String, String> headers = new HashMap<String, String>();
        HttpServletRequest hsrt = (HttpServletRequest) request;
        Enumeration<String> headerNames = hsrt.getHeaderNames();
        
        while (headerNames.hasMoreElements()) {
            String key = (String) headerNames.nextElement();
            String value = hsrt.getHeader(key);
            headers.put(key, value);
        }
        boolean upgraded = h2ic.handleHTTP2UpgradeRequest(headers);
        if (!upgraded) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "returning: http2 connection initialization failed");
            }
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    }
394618
private void addQueryParams(final Request request) {
        if (log != null) {
            request.addQueryParam("Log", log.toString());
        }

        if (absoluteMessageDate != null) {
            request.addQueryParam("MessageDate", absoluteMessageDate.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeMessageDate != null) {
            request.addQueryDateRange("MessageDate", rangeMessageDate);
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
61197
static void modify(HttpServletRequest httpRequest,
                       HttpServletResponse httpResponse,
                       Body body,
                       RequestWrapper requestWrapper,
                       ResponseWrapper responseWrapper,
                       ExceptionMapper exceptionMapper,
                       Exception e) {

        ExceptionHandlerImpl handler = exceptionMapper.getHandler(e);

        if (handler != null) {
            handler.handle(e, requestWrapper, responseWrapper);
            String bodyAfterFilter = responseWrapper.getDelegate().body();

            if (bodyAfterFilter != null) {
                body.set(bodyAfterFilter);
            }
        } else {
            LOG.error("", e);

            httpResponse.setStatus(500);

            if (CustomErrorPages.existsFor(500)) {
                requestWrapper.setDelegate(RequestResponseFactory.create(httpRequest));
                responseWrapper.setDelegate(RequestResponseFactory.create(httpResponse));
                body.set(CustomErrorPages.getFor(500, requestWrapper, responseWrapper));
            } else {
                body.set(CustomErrorPages.INTERNAL_ERROR);
            }
        }
    }
614728
private void addHeadersToRequest(HttpRequestBase httpRequest, Request<?> request) {

        httpRequest.addHeader(HttpHeaders.HOST, getHostHeaderValue(request.getEndpoint()));

        // Copy over any other headers already in our request
        for (Entry<String, String> entry : request.getHeaders().entrySet()) {
            /*
             * HttpClient4 fills in the Content-Length header and complains if
             * it's already present, so we skip it here. We also skip the Host
             * header to avoid sending it twice, which will interfere with some
             * signing schemes.
             */
            if (!(ignoreHeaders.contains(entry.getKey()))) {
                httpRequest.addHeader(entry.getKey(), entry.getValue());
            }
        }

        /* Set content type and encoding */
        if (httpRequest.getHeaders(HttpHeaders.CONTENT_TYPE) == null || httpRequest
                .getHeaders
                        (HttpHeaders.CONTENT_TYPE).length == 0) {
            httpRequest.addHeader(HttpHeaders.CONTENT_TYPE,
                    "application/x-www-form-urlencoded; " +
                            "charset=" + DEFAULT_ENCODING.toLowerCase());
        }
    }
526495
private void handleExpansionRequest(final Request request) {
		String[] paramValue = request.getParameterValues(getId() + ".expanded");

		if (paramValue == null) {
			paramValue = new String[0];
		}

		String[] expandedRows = removeEmptyStrings(paramValue);

		List<Integer> oldExpansions = getExpandedRows();
		List<Integer> expansions;

		TableDataModel model = getDataModel();

		if (model.getRowCount() == 0) {
			setExpandedRows(new ArrayList<Integer>());
			return;
		} else if (getPaginationMode() == PaginationMode.NONE
				|| getPaginationMode() == PaginationMode.CLIENT
				|| oldExpansions == null) {
			expansions = new ArrayList<>(expandedRows.length);
		} else {
			// row expansions only apply to the current page
			expansions = new ArrayList<>(oldExpansions);

			int startRow = getCurrentPageStartRow();
			int endRow = getCurrentPageEndRow();
			expansions.removeAll(getRowIds(startRow, endRow));
		}

		for (String expandedRow : expandedRows) {
			try {
				expansions.add(Integer.parseInt(expandedRow));
			} catch (NumberFormatException e) {
				LOG.warn("Invalid row id for expansion: " + expandedRow);
			}
		}

		// For tree tables, we also have to tell the nodes to expand themselves
		if (model instanceof TreeTableDataModel) {
			TreeTableDataModel treeModel = (TreeTableDataModel) model;

			// We need the expanded indices sorted, as expanding/collapsing sections alters row indices
			Collections.sort(expansions);

			for (int row = 0; row < treeModel.getRowCount(); row++) {
				for (Iterator<TreeNode> i = treeModel.getNodeAtLine(row).depthFirst(); i.hasNext();) {
					TableTreeNode node = (TableTreeNode) i.next();
					node.setExpanded(false);
				}
			}

			for (int i = expansions.size() - 1; i >= 0; i--) {
				treeModel.getNodeAtLine(expansions.get(i)).setExpanded(true);
			}
		}

		setExpandedRows(expansions);
	}
1197766
def edit_resource(self, request):
        
        self.location_query = request.uri_query
        self.payload = (request.content_type, request.payload)
439590
public void addRequestProp(String key, Object value) {
        if (key == null || value == null) {
            return;
        }
        if (requestProps == null) {
            requestProps = new HashMap<String, Object>(16);
        }
        requestProps.put(key, value);
    }