Override to set the content type of the response and reset the headers.

@param request The request being serviced.
348178
@Override
	public void preparePaint(final Request request) {
		UIContext uic = UIContextHolder.getCurrent();
		Headers headers = uic.getUI().getHeaders();
		headers.reset();
		headers.setContentType(WebUtilities.CONTENT_TYPE_XML);

		super.preparePaint(request);
	}
1213450
@Override
	public void handleRequest(final Request request) {
		if (!isDisabled()) {
			final SelectToggleModel model = getComponentModel();
			String requestParam = request.getParameter(getId());

			final State newValue;
			if ("all".equals(requestParam)) {
				newValue = State.ALL;
			} else if ("none".equals(requestParam)) {
				newValue = State.NONE;
			} else if ("some".equals(requestParam)) {
				newValue = State.SOME;
			} else {
				newValue = model.state;
			}

			if (!newValue.equals(model.state)) {
				setState(newValue);
			}
			if (!model.clientSide && model.target != null && !State.SOME.equals(newValue)) {
				// We need to change the selections *after* all components
				// Have updated themselves from the request, as they may change
				// their values when their handleRequest methods are called.
				invokeLater(new Runnable() {
					@Override
					public void run() {
						setSelections(model.target, State.ALL.equals(newValue));
					}
				});
			}
		}
	}
1306922
public CORSRequestType checkRequestType(final HttpServletRequest request) {
		CORSRequestType requestType = CORSRequestType.INVALID_CORS;
		if (request == null) {
			throw new IllegalArgumentException(
					"HttpServletRequest object is null");
		}
		String originHeader = request.getHeader(REQUEST_HEADER_ORIGIN);
		// Section 6.1.1 and Section 6.2.1
		if (originHeader != null) {
			if (originHeader.isEmpty()) {
				requestType = CORSRequestType.INVALID_CORS;
			} else if (!isValidOrigin(originHeader)) {
				requestType = CORSRequestType.INVALID_CORS;
			} else {
				String method = StringUtils.trimToEmpty(request.getMethod());
				if (HTTP_METHODS.contains(method)) {
					if ("OPTIONS".equals(method)) {
						String accessControlRequestMethodHeader
								= request.getHeader(REQUEST_HEADER_ACCESS_CONTROL_REQUEST_METHOD);
						if (StringUtils.isNotBlank(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.PRE_FLIGHT;
						} else if (StringUtils.isWhitespace(accessControlRequestMethodHeader)) {
							requestType = CORSRequestType.INVALID_CORS;
						} else {
							requestType = CORSRequestType.ACTUAL;
						}
					} else if ("GET".equals(method) || "HEAD".equals(method)) {
						requestType = CORSRequestType.SIMPLE;
					} else if ("POST".equals(method)) {
						String contentType = request.getContentType();
						if (contentType != null) {
							contentType = contentType.toLowerCase().trim();
							if (SIMPLE_HTTP_REQUEST_CONTENT_TYPE_VALUES
									.contains(contentType)) {
								requestType = CORSRequestType.SIMPLE;
							} else {
								requestType = CORSRequestType.ACTUAL;
							}
						}
					} else if (COMPLEX_HTTP_METHODS.contains(method)) {
						requestType = CORSRequestType.ACTUAL;
					}
				}
			}
		} else {
			requestType = CORSRequestType.NOT_CORS;
		}

		return requestType;
	}
659011
public void setFeedback(SetFeedbackRequest request) {
        checkNotNull(request, "object request should not be null.");
        if (request.getEmail() != null && request.getEmail().trim().length() > 0) {
            checkIsEmail(request.getEmail());
        }
        if (request.getType() == null) {
            request.setType(1);
        }
        if (!Arrays.asList(new Integer[] { 1, 2, 3 }).contains(request.getType())) {
            throw new IllegalArgumentException("illegal type.");
        }

        InternalRequest internalRequest = this.createRequest("feedback", request, HttpMethodName.PUT);

        // fill in the request payload
        internalRequest = fillRequestPayload(internalRequest, JsonUtils.toJsonString(request));

        this.invokeHttpClient(internalRequest, SesResponse.class);
    }
610483
public void setContentType(String contentType) 
    {
        if (isCommitted())
            return;
        
        if (contentType==null)
        {
            _mimeType=null;
            _header.remove(HttpFields.__ContentType);
        }
        else
        {
            // Look for encoding in contentType
            int i0=contentType.indexOf(';');
            
            if (i0>0)
            {
                // Strip params off mimetype
                _mimeType=contentType.substring(0,i0).trim();
                
                // Look for charset
                int i1=contentType.indexOf("charset=",i0);
                if (i1>=0)
                {
                    i1+=8;
                    int i2 = contentType.indexOf(' ',i1);
                    _characterEncoding = (0<i2)
                    ? contentType.substring(i1,i2)
                                    : contentType.substring(i1);
                    _characterEncoding = QuotedStringTokenizer.unquote(_characterEncoding);
                }
                else // No encoding in the params.
                {
                    if (_characterEncoding!=null)
                        // Add any previously set encoding.
                        contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
                }
            }
            else // No encoding and no other params
            {
                _mimeType=contentType;
                // Add any previously set encoding.
                if (_characterEncoding!=null)
                    contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
            }
            
            _header.put(HttpFields.__ContentType,contentType);
        }
    }
519618
@Override
    public void writeTenant(MutableHttpRequest<?> request, Serializable tenant) {
        if (tenant instanceof CharSequence) {
            request.header(getHeaderName(), (CharSequence) tenant);
        }
    }
627517
private void addPostParams(final Request request) {
        if (enabled != null) {
            request.addPostParam("Enabled", enabled.toString());
        }

        if (webhookUrl != null) {
            request.addPostParam("WebhookUrl", webhookUrl.toString());
        }

        if (webhookMethod != null) {
            request.addPostParam("WebhookMethod", webhookMethod);
        }
    }
708909
@Override
	public void handleRequest(final Request request) {
		if (isDisabled()) {
			// Protect against client-side tampering of disabled/read-only fields.
			return;
		}

		// Remember which client side tab we were on.
		String[] indicesStr = request.getParameterValues(getId());

		if (indicesStr != null && indicesStr.length > 0) {
			List<Integer> oldIndices = getActiveIndices();
			List<Integer> changes = new ArrayList<>(1);
			int[] indices = new int[indicesStr.length];

			if (Util.empty(indicesStr[0])) {
				// Special case - no tab selected
				if (getType() == TYPE_ACCORDION) {
					indices = null;
				} else {
					int idx = findFirstVisibleTab();
					indices = new int[idx];
				}
			} else {
				// Normal case - one or more tabs selected
				for (int i = 0; i < indices.length; i++) {
					int clientIndex = Integer.parseInt(indicesStr[i]);
					int idx = clientIndexToTabIndex(clientIndex);
					indices[i] = idx;

					if (!oldIndices.contains(idx)) {
						// Check for a server mode tab and set focus
						WTab tab = getTab(idx);
						if (TabMode.SERVER.equals(tab.getMode()) && UIContextHolder.getCurrent().getFocussed() == null) {
							tab.setFocussed();
						}
						changes.add(idx);
					}
				}
			}

			setActiveIndices(indices);

			// Invoke action if tab selection has changed
			final Action action = getActionOnChange();

			if (action != null && !changes.isEmpty()) {
				final ActionEvent event = new ActionEvent(this, changes.toString(), null);

				Runnable later = new Runnable() {
					@Override
					public void run() {
						action.execute(event);
					}
				};

				invokeLater(later);
			}
		}

		String showHeadOnlyStr = request.getParameter(getId() + ".showHeadOnly");

		if (showHeadOnlyStr != null) {
			boolean showHeadOnly = "true".equals(showHeadOnlyStr);
			setShowHeadOnly(showHeadOnly);
		}
	}
895272
private void addPostParams(final Request request) {
        if (defaults != null) {
            request.addPostParam("Defaults", Converter.mapToJson(defaults));
        }
    }
1013611
public final void setContent(String content)
    {
        //clear non relevant flags
        this.contentBinary=null;
        this.contentParts=null;
        this.contentType=ContentType.STRING;

        this.contentString=content;
    }
1005041
private void addPostParams(final Request request) {
        if (language != null) {
            request.addPostParam("Language", language);
        }

        if (value != null) {
            request.addPostParam("Value", value);
        }

        if (synonymOf != null) {
            request.addPostParam("SynonymOf", synonymOf.toString());
        }
    }
103321
public void setContent(final byte[] content,
                         final String contentType) throws HttpException {
    if (!(method instanceof HttpEntityEnclosingRequestBase)) {
      throw new HttpException("Invalid operation for method " +
                               method.getMethod());
    }

    final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase)method;

    ByteArrayEntity entity = new ByteArrayEntity(content);
    entity.setContentType(contentType);
    eem.setEntity(entity);
  }
176655
private void addQueryParams(final Request request) {
        if (bindingType != null) {
            for (UserBinding.BindingType prop : bindingType) {
                request.addQueryParam("BindingType", prop.toString());
            }
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
1174440
private void addPostParams(final Request request) {
        if (styleSheet != null) {
            request.addPostParam("StyleSheet", Converter.mapToJson(styleSheet));
        }
    }
668949
public void enableDKIM(EnableDKIMRequest request) {
        checkNotNull(request, "object request should not be null.");
        assertStringNotNullOrEmpty(request.getDomainName(), "object domainName should not be null or empty");

        InternalRequest internalRequest =
                this.createRequest("verifiedDomain", request, HttpMethodName.PUT, request.getDomainName());
        internalRequest.addParameter("enable", "enableDkim");

        this.invokeHttpClient(internalRequest, SesResponse.class);
    }
372210
private void addPostParams(final Request request) {
        if (read != null) {
            request.addPostParam("Read", read.toString());
        }

        if (write != null) {
            request.addPostParam("Write", write.toString());
        }

        if (manage != null) {
            request.addPostParam("Manage", manage.toString());
        }
    }
1234017
function method (request) {

    if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
        request.headers.set('X-HTTP-Method-Override', request.method);
        request.method = 'POST';
    }

}