本文整理了Java中org.simpleframework.http.Request.getMethod
方法的一些代码示例,展示了Request.getMethod
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getMethod
方法的具体详情如下:
包路径:org.simpleframework.http.Request
类名称:Request
方法名:getMethod
暂无
代码示例来源:origin: mpetazzoni/ttorrent
response.setDate("Date", System.currentTimeMillis());
if ("GET".equalsIgnoreCase(request.getMethod())) {
代码示例来源:origin: jersey/jersey
@Override
public void handle(final Request request, final Response response) {
final ResponseWriter responseWriter = new ResponseWriter(response, scheduler);
final URI baseUri = getBaseUri(request);
final URI requestUri = getRequestUri(request, baseUri);
try {
final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate());
requestContext.setEntityStream(request.getInputStream());
for (final String headerName : request.getNames()) {
requestContext.headers(headerName, request.getValue(headerName));
}
requestContext.setWriter(responseWriter);
requestContext.setRequestScopedInitializer(injectionManager -> {
injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
});
appHandler.handle(requestContext);
} catch (final Exception ex) {
throw new RuntimeException(ex);
} finally {
if (!responseWriter.isSuspended()) {
close(response);
}
}
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This can be used to get the HTTP method for this request. The
* HTTP specification RFC 2616 specifies the HTTP request methods
* in section 9, Method Definitions. Typically this will be a
* GET, POST or a HEAD method, although any string is possible.
*
* @return the request method for this request message
*/
public String getMethod() {
return request.getMethod();
}
代码示例来源:origin: org.simpleframework/simple
/**
* This can be used to get the HTTP method for this request. The
* HTTP specification RFC 2616 specifies the HTTP request methods
* in section 9, Method Definitions. Typically this will be a
* GET, POST or a HEAD method, although any string is possible.
*
* @return the request method for this request message
*/
public String getMethod() {
return request.getMethod();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This can be used to get the HTTP method for this request. The
* HTTP specification RFC 2616 specifies the HTTP request methods
* in section 9, Method Definitions. Typically this will be a
* GET, POST or a HEAD method, although any string is possible.
*
* @return the request method for this request message
*/
public String getMethod() {
return request.getMethod();
}
代码示例来源:origin: org.restlet/org.restlet.ext.simple
/**
* Returns the request method.
*
* @return The request method.
*/
@Override
public String getMethod() {
return this.request.getMethod();
}
代码示例来源:origin: restx/restx
@Override
public String getHttpMethod() {
return request.getMethod();
}
代码示例来源:origin: CodeStory/fluent-http
@Override
public String method() {
return request.getMethod();
}
代码示例来源:origin: io.restx/restx-server-simple
@Override
public String getHttpMethod() {
return request.getMethod();
}
代码示例来源:origin: lantunes/fixd
public String getMethod() {
return request.getMethod();
}
代码示例来源:origin: lantunes/fixd
public String getMethod() {
return request.getMethod();
}
代码示例来源:origin: opendedup/sdfs
public void processIo(Request req, Response rsp, String path) throws IOException {
String[] tokens = path.split("/");
switch (req.getMethod()) {
case Method.PUT:
this.handlePut(req, rsp, tokens);
break;
case Method.GET:
this.handleGet(req, rsp, tokens);
break;
case Method.DELETE:
this.handleDelete(req, rsp, tokens);
break;
default:
throw new IOException("method not implemented " + req.getMethod());
}
}
代码示例来源:origin: miltonio/milton2
@Override
public Method getMethod() {
String s = baseRequest.getMethod().toUpperCase();
try {
return Method.valueOf(s);
} catch (IllegalArgumentException e) {
String ua = getUserAgentHeader();
String ip = getRemoteAddr();
throw new RuntimeException("No such method: " + s + " Requested by user-agent: " + ua + " from remote address: " + ip);
}
}
代码示例来源:origin: miltonio/milton2
@Override
public String toString() {
return request.getMethod() + " " + request.getAddress().toString();
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server
public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse cResponse) throws IOException {
int code = cResponse.getStatus();
String text = Status.getDescription(code);
String method = request.getMethod();
response.setCode(code);
response.setDescription(text);
if (!method.equalsIgnoreCase("HEAD") && contentLength != -1 && contentLength < Integer.MAX_VALUE) {
response.setContentLength((int) contentLength);
}
for (Map.Entry<String, List<Object>> e : cResponse.getHttpHeaders().entrySet()) {
for (Object value : e.getValue()) {
response.setValue(e.getKey(), ContainerResponse.getHeaderValue(value));
}
}
return response.getOutputStream();
}
代码示例来源:origin: lantunes/fixd
public ResolvedRequest resolve(Request request) {
ResolvedRequest resolved = new ResolvedRequest();
String method = request.getMethod();
String path = RequestUtils.getUndecodedPath(request);
ContentType requestContentType = request.getContentType();
/* get the route and the handler for this request */
Route route = router.route(path);
if (route == null) {
logger.error("could not find a route for " + path);
resolved.errorStatus = Status.NOT_FOUND;
return resolved;
}
String contentType = requestContentType != null ?
requestContentType.getType() : null;
HandlerKey key = new HandlerKey(method, route, contentType);
RequestHandlerImpl handler = handlerMap.get(key);
if (handler == null) {
logger.error("could not find a handler for " +
method + " - " + path + " - " + contentType);
resolved.errorStatus = Status.METHOD_NOT_ALLOWED;
return resolved;
}
resolved.handler = handler;
resolved.route = route;
resolved.key = key;
return resolved;
}
代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server
public void handle(Request request, Response response) {
WebApplication target = application;
final URI baseUri = getBaseUri(request);
final URI requestUri = baseUri.resolve(request.getTarget());
try {
final ContainerRequest cRequest = new ContainerRequest(
target,
request.getMethod(),
baseUri,
requestUri,
getHeaders(request),
request.getInputStream());
target.handleRequest(cRequest, new Writer(request, response));
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
close(response);
}
}
代码示例来源:origin: kristofa/mock-http-server
public static FullHttpRequest convert(final Request request) {
byte[] data = null;
try {
final InputStream inputStream = request.getInputStream();
try {
data = IOUtils.toByteArray(inputStream);
} finally {
inputStream.close();
}
} catch (final IOException e) {
LOGGER.error("IOException when getting request content.", e);
}
final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl();
httpRequest.domain(request.getAddress().getDomain());
httpRequest.port(request.getAddress().getPort());
httpRequest.method(Method.valueOf(request.getMethod()));
httpRequest.path(request.getPath().getPath());
if (data.length > 0) {
httpRequest.content(data);
}
for (final String headerField : request.getNames()) {
for (final String headerFieldValue : request.getValues(headerField)) {
httpRequest.httpMessageHeader(headerField, headerFieldValue);
}
}
for (final Entry<String, String> entry : request.getQuery().entrySet()) {
httpRequest.queryParameter(entry.getKey(), entry.getValue());
}
return httpRequest;
}
代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http
@Override
public void handle(final Request request, final Response response) {
final ResponseWriter responseWriter = new ResponseWriter(response, scheduler);
final URI baseUri = getBaseUri(request);
final URI requestUri = getRequestUri(request, baseUri);
try {
final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate());
requestContext.setEntityStream(request.getInputStream());
for (final String headerName : request.getNames()) {
requestContext.headers(headerName, request.getValue(headerName));
}
requestContext.setWriter(responseWriter);
requestContext.setRequestScopedInitializer(injectionManager -> {
injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
});
appHandler.handle(requestContext);
} catch (final Exception ex) {
throw new RuntimeException(ex);
} finally {
if (!responseWriter.isSuspended()) {
close(response);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!