All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frameworkset.http.ServletServerHttpRequest Maven / Gradle / Ivy

Go to download

bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com

There is a newer version: 6.2.8
Show newest version
/*
 *  Copyright 2008-2010 biaoping.yin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.frameworkset.http;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.frameworkset.util.Assert;
import org.frameworkset.util.annotations.HttpMethod;

/**
 * 

Title: ServletServerHttpRequest.java

*

Description:

*

bboss workgroup

*

Copyright (c) 2008

* @Date 2010-11-21 * @author biaoping.yin * @version 1.0 */ public class ServletServerHttpRequest implements ServerHttpRequest { private final HttpServletRequest servletRequest; private HttpHeaders headers; /** * Construct a new instance of the ServletServerHttpRequest based on the given {@link HttpServletRequest} * @param servletRequest the HttpServletRequest */ public ServletServerHttpRequest(HttpServletRequest servletRequest) { Assert.notNull(servletRequest, "'servletRequest' must not be null"); this.servletRequest = servletRequest; } public HttpMethod getMethod() { return HttpMethod.valueOf(this.servletRequest.getMethod()); } public URI getURI() { try { return new URI(servletRequest.getScheme(), null, servletRequest.getServerName(), servletRequest.getServerPort(), servletRequest.getRequestURI(), servletRequest.getQueryString(), null); } catch (URISyntaxException ex) { throw new IllegalStateException("Could not get HttpServletRequest URI: " + ex.getMessage(), ex); } } public HttpHeaders getHeaders() { if (this.headers == null) { this.headers = new HttpHeaders(); for (Enumeration headerNames = this.servletRequest.getHeaderNames(); headerNames.hasMoreElements();) { String headerName = (String) headerNames.nextElement(); for (Enumeration headerValues = this.servletRequest.getHeaders(headerName); headerValues.hasMoreElements();) { String headerValue = (String) headerValues.nextElement(); this.headers.add(headerName, headerValue); } } } return this.headers; } public InputStream getBody() throws IOException { return this.servletRequest.getInputStream(); } public HttpServletRequest getServletRequest() { return servletRequest; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy