本文整理了Java中org.eclipse.jetty.server.Request.getContentType
方法的一些代码示例,展示了Request.getContentType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getContentType
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Request
类名称:Request
方法名:getContentType
暂无
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public void handle(String pathInContext, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException {
String redirectHeader = httpRequest.getHeader("X-REDIRECT");
if (redirectHeader != null && !redirectAlreadyPerformed) {
redirectAlreadyPerformed = true;
httpResponse.setStatus(Integer.valueOf(redirectHeader));
httpResponse.setContentLength(0);
httpResponse.setHeader(LOCATION.toString(), getTargetUrl());
} else {
receivedContentType = request.getContentType();
httpResponse.setStatus(200);
int len = request.getContentLength();
httpResponse.setContentLength(len);
if (len > 0) {
byte[] buffer = new byte[len];
IOUtils.read(request.getInputStream(), buffer);
httpResponse.getOutputStream().write(buffer);
}
}
httpResponse.getOutputStream().flush();
httpResponse.getOutputStream().close();
}
};
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final String target, final Request baseRequest,
final HttpServletRequest request, final HttpServletResponse response) throws IOException,
ServletException {
try {
baseRequest.setHandled(true);
String type = baseRequest.getContentType();
boolean multipart = false;
if (type != null && type.toLowerCase().startsWith(MediaType.multipart.name())) {
baseRequest.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, multiPartConfig);
multipart = true;
}
ServletServletRequest nreq = new ServletServletRequest(request, tmpdir, multipart)
.with(upgrade(baseRequest, request, response, webSocketServerFactory));
dispatcher.handle(nreq, new JettyResponse(nreq, response));
} catch (IOException | ServletException | RuntimeException ex) {
baseRequest.setHandled(false);
log.error("execution of: " + target + " resulted in error", ex);
throw ex;
} catch (Throwable ex) {
baseRequest.setHandled(false);
log.error("execution of: " + target + " resulted in error", ex);
throw new IllegalStateException(ex);
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
@Override
public String getCharacterEncoding()
{
if (_characterEncoding==null)
getContentType();
return _characterEncoding;
}
代码示例来源:origin: jenkinsci/winstone
@Override
public String getCharacterEncoding()
{
if (_characterEncoding==null)
getContentType();
return _characterEncoding;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.jetty.server
@Override
public Collection<Part> getParts() throws IOException, ServletException
{
if (getContentType() == null || !getContentType().startsWith("multipart/form-data"))
throw new ServletException("Content-Type != multipart/form-data");
return getParts(null);
}
代码示例来源:origin: Nextdoor/bender
@Override
public Collection<Part> getParts() throws IOException, ServletException
{
if (getContentType() == null || !getContentType().startsWith("multipart/form-data"))
throw new ServletException("Content-Type != multipart/form-data");
return getParts(null);
}
代码示例来源:origin: jenkinsci/winstone
@Override
public Collection<Part> getParts() throws IOException, ServletException
{
if (getContentType() == null ||
!MimeTypes.Type.MULTIPART_FORM_DATA.is(HttpFields.valueParameters(getContentType(),null)))
throw new ServletException("Content-Type != multipart/form-data");
return getParts(null);
}
代码示例来源:origin: kiegroup/droolsjbpm-integration
@Override
public void handle( Request request, HttpServletResponse response ) {
contentType.set(request.getContentType());
response.setStatus(HTTP_OK);
}
};
代码示例来源:origin: kiegroup/droolsjbpm-integration
@Override
public void handle( Request request, HttpServletResponse response ) {
contentType.set(request.getContentType());
response.setStatus(HTTP_OK);
}
};
代码示例来源:origin: kiegroup/droolsjbpm-integration
@Override
public void handle( Request request, HttpServletResponse response ) {
contentType.set(request.getContentType());
response.setStatus(HTTP_OK);
}
};
代码示例来源:origin: kiegroup/droolsjbpm-integration
@Override
public void handle( Request request, HttpServletResponse response ) {
body.set(new String(read()));
contentType.set(request.getContentType());
response.setStatus(HTTP_OK);
}
};
代码示例来源:origin: kiegroup/droolsjbpm-integration
@Override
public void handle( Request request, HttpServletResponse response ) {
body.set(new String(read()));
contentType.set(request.getContentType());
response.setStatus(HTTP_OK);
}
};
代码示例来源:origin: org.keycloak/keycloak-jetty94-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-jetty93-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/spring-boot-container-bundle
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-jetty81-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-jetty91-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-jetty92-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-saml-jetty94-adapter
public void saveRequest() {
// remember the current URI
HttpSession session = myRequest.getSession();
synchronized (session) {
// But only if it is not set already, or we save every uri that leads to a login form redirect
if (session.getAttribute(FormAuthenticator.__J_URI) == null) {
StringBuffer buf = myRequest.getRequestURL();
if (myRequest.getQueryString() != null)
buf.append("?").append(myRequest.getQueryString());
session.setAttribute(FormAuthenticator.__J_URI, buf.toString());
session.setAttribute(JettyHttpFacade.__J_METHOD, myRequest.getMethod());
if ("application/x-www-form-urlencoded".equals(myRequest.getContentType()) && "POST".equalsIgnoreCase(myRequest.getMethod())) {
MultiMap<String> formParameters = extractFormParameters(myRequest);
MultivaluedHashMap<String, String> map = new MultivaluedHashMap<String, String>();
for (String key : formParameters.keySet()) {
for (Object value : formParameters.getValues(key)) {
map.add(key, (String) value);
}
}
session.setAttribute(CACHED_FORM_PARAMETERS, map);
}
}
}
}
代码示例来源:origin: jenkinsci/winstone
private MultiParts newMultiParts(ServletInputStream inputStream, String contentType, MultipartConfigElement config, Object object) throws IOException
{
MultiPartFormDataCompliance compliance = getHttpChannel().getHttpConfiguration().getMultipartFormDataCompliance();
if(LOG.isDebugEnabled())
LOG.debug("newMultiParts {} {}",compliance, this);
switch(compliance)
{
case RFC7578:
return new MultiParts.MultiPartsHttpParser(getInputStream(), getContentType(), config,
(_context != null?(File)_context.getAttribute("javax.servlet.context.tempdir"):null), this);
case LEGACY:
default:
return new MultiParts.MultiPartsUtilParser(getInputStream(), getContentType(), config,
(_context != null?(File)_context.getAttribute("javax.servlet.context.tempdir"):null), this);
}
}
内容来源于网络,如有侵权,请联系作者删除!