org.simpleframework.http.Request.getMethod()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(326)

本文整理了Java中org.simpleframework.http.Request.getMethod方法的一些代码示例,展示了Request.getMethod的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getMethod方法的具体详情如下:
包路径:org.simpleframework.http.Request
类名称:Request
方法名:getMethod

Request.getMethod介绍

暂无

代码示例

代码示例来源:origin: mpetazzoni/ttorrent

  1. response.setDate("Date", System.currentTimeMillis());
  2. if ("GET".equalsIgnoreCase(request.getMethod())) {

代码示例来源:origin: jersey/jersey

  1. @Override
  2. public void handle(final Request request, final Response response) {
  3. final ResponseWriter responseWriter = new ResponseWriter(response, scheduler);
  4. final URI baseUri = getBaseUri(request);
  5. final URI requestUri = getRequestUri(request, baseUri);
  6. try {
  7. final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
  8. request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate());
  9. requestContext.setEntityStream(request.getInputStream());
  10. for (final String headerName : request.getNames()) {
  11. requestContext.headers(headerName, request.getValue(headerName));
  12. }
  13. requestContext.setWriter(responseWriter);
  14. requestContext.setRequestScopedInitializer(injectionManager -> {
  15. injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
  16. injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
  17. });
  18. appHandler.handle(requestContext);
  19. } catch (final Exception ex) {
  20. throw new RuntimeException(ex);
  21. } finally {
  22. if (!responseWriter.isSuspended()) {
  23. close(response);
  24. }
  25. }
  26. }

代码示例来源:origin: ngallagher/simpleframework

  1. /**
  2. * This can be used to get the HTTP method for this request. The
  3. * HTTP specification RFC 2616 specifies the HTTP request methods
  4. * in section 9, Method Definitions. Typically this will be a
  5. * GET, POST or a HEAD method, although any string is possible.
  6. *
  7. * @return the request method for this request message
  8. */
  9. public String getMethod() {
  10. return request.getMethod();
  11. }

代码示例来源:origin: org.simpleframework/simple

  1. /**
  2. * This can be used to get the HTTP method for this request. The
  3. * HTTP specification RFC 2616 specifies the HTTP request methods
  4. * in section 9, Method Definitions. Typically this will be a
  5. * GET, POST or a HEAD method, although any string is possible.
  6. *
  7. * @return the request method for this request message
  8. */
  9. public String getMethod() {
  10. return request.getMethod();
  11. }

代码示例来源:origin: org.simpleframework/simple-http

  1. /**
  2. * This can be used to get the HTTP method for this request. The
  3. * HTTP specification RFC 2616 specifies the HTTP request methods
  4. * in section 9, Method Definitions. Typically this will be a
  5. * GET, POST or a HEAD method, although any string is possible.
  6. *
  7. * @return the request method for this request message
  8. */
  9. public String getMethod() {
  10. return request.getMethod();
  11. }

代码示例来源:origin: org.restlet/org.restlet.ext.simple

  1. /**
  2. * Returns the request method.
  3. *
  4. * @return The request method.
  5. */
  6. @Override
  7. public String getMethod() {
  8. return this.request.getMethod();
  9. }

代码示例来源:origin: restx/restx

  1. @Override
  2. public String getHttpMethod() {
  3. return request.getMethod();
  4. }

代码示例来源:origin: CodeStory/fluent-http

  1. @Override
  2. public String method() {
  3. return request.getMethod();
  4. }

代码示例来源:origin: io.restx/restx-server-simple

  1. @Override
  2. public String getHttpMethod() {
  3. return request.getMethod();
  4. }

代码示例来源:origin: lantunes/fixd

  1. public String getMethod() {
  2. return request.getMethod();
  3. }

代码示例来源:origin: lantunes/fixd

  1. public String getMethod() {
  2. return request.getMethod();
  3. }

代码示例来源:origin: opendedup/sdfs

  1. public void processIo(Request req, Response rsp, String path) throws IOException {
  2. String[] tokens = path.split("/");
  3. switch (req.getMethod()) {
  4. case Method.PUT:
  5. this.handlePut(req, rsp, tokens);
  6. break;
  7. case Method.GET:
  8. this.handleGet(req, rsp, tokens);
  9. break;
  10. case Method.DELETE:
  11. this.handleDelete(req, rsp, tokens);
  12. break;
  13. default:
  14. throw new IOException("method not implemented " + req.getMethod());
  15. }
  16. }

代码示例来源:origin: miltonio/milton2

  1. @Override
  2. public Method getMethod() {
  3. String s = baseRequest.getMethod().toUpperCase();
  4. try {
  5. return Method.valueOf(s);
  6. } catch (IllegalArgumentException e) {
  7. String ua = getUserAgentHeader();
  8. String ip = getRemoteAddr();
  9. throw new RuntimeException("No such method: " + s + " Requested by user-agent: " + ua + " from remote address: " + ip);
  10. }
  11. }

代码示例来源:origin: miltonio/milton2

  1. @Override
  2. public String toString() {
  3. return request.getMethod() + " " + request.getAddress().toString();
  4. }

代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server

  1. public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse cResponse) throws IOException {
  2. int code = cResponse.getStatus();
  3. String text = Status.getDescription(code);
  4. String method = request.getMethod();
  5. response.setCode(code);
  6. response.setDescription(text);
  7. if (!method.equalsIgnoreCase("HEAD") && contentLength != -1 && contentLength < Integer.MAX_VALUE) {
  8. response.setContentLength((int) contentLength);
  9. }
  10. for (Map.Entry<String, List<Object>> e : cResponse.getHttpHeaders().entrySet()) {
  11. for (Object value : e.getValue()) {
  12. response.setValue(e.getKey(), ContainerResponse.getHeaderValue(value));
  13. }
  14. }
  15. return response.getOutputStream();
  16. }

代码示例来源:origin: lantunes/fixd

  1. public ResolvedRequest resolve(Request request) {
  2. ResolvedRequest resolved = new ResolvedRequest();
  3. String method = request.getMethod();
  4. String path = RequestUtils.getUndecodedPath(request);
  5. ContentType requestContentType = request.getContentType();
  6. /* get the route and the handler for this request */
  7. Route route = router.route(path);
  8. if (route == null) {
  9. logger.error("could not find a route for " + path);
  10. resolved.errorStatus = Status.NOT_FOUND;
  11. return resolved;
  12. }
  13. String contentType = requestContentType != null ?
  14. requestContentType.getType() : null;
  15. HandlerKey key = new HandlerKey(method, route, contentType);
  16. RequestHandlerImpl handler = handlerMap.get(key);
  17. if (handler == null) {
  18. logger.error("could not find a handler for " +
  19. method + " - " + path + " - " + contentType);
  20. resolved.errorStatus = Status.METHOD_NOT_ALLOWED;
  21. return resolved;
  22. }
  23. resolved.handler = handler;
  24. resolved.route = route;
  25. resolved.key = key;
  26. return resolved;
  27. }

代码示例来源:origin: com.sun.jersey.contribs/jersey-simple-server

  1. public void handle(Request request, Response response) {
  2. WebApplication target = application;
  3. final URI baseUri = getBaseUri(request);
  4. final URI requestUri = baseUri.resolve(request.getTarget());
  5. try {
  6. final ContainerRequest cRequest = new ContainerRequest(
  7. target,
  8. request.getMethod(),
  9. baseUri,
  10. requestUri,
  11. getHeaders(request),
  12. request.getInputStream());
  13. target.handleRequest(cRequest, new Writer(request, response));
  14. } catch (Exception ex) {
  15. throw new RuntimeException(ex);
  16. } finally {
  17. close(response);
  18. }
  19. }

代码示例来源:origin: kristofa/mock-http-server

  1. public static FullHttpRequest convert(final Request request) {
  2. byte[] data = null;
  3. try {
  4. final InputStream inputStream = request.getInputStream();
  5. try {
  6. data = IOUtils.toByteArray(inputStream);
  7. } finally {
  8. inputStream.close();
  9. }
  10. } catch (final IOException e) {
  11. LOGGER.error("IOException when getting request content.", e);
  12. }
  13. final FullHttpRequestImpl httpRequest = new FullHttpRequestImpl();
  14. httpRequest.domain(request.getAddress().getDomain());
  15. httpRequest.port(request.getAddress().getPort());
  16. httpRequest.method(Method.valueOf(request.getMethod()));
  17. httpRequest.path(request.getPath().getPath());
  18. if (data.length > 0) {
  19. httpRequest.content(data);
  20. }
  21. for (final String headerField : request.getNames()) {
  22. for (final String headerFieldValue : request.getValues(headerField)) {
  23. httpRequest.httpMessageHeader(headerField, headerFieldValue);
  24. }
  25. }
  26. for (final Entry<String, String> entry : request.getQuery().entrySet()) {
  27. httpRequest.queryParameter(entry.getKey(), entry.getValue());
  28. }
  29. return httpRequest;
  30. }

代码示例来源:origin: org.glassfish.jersey.containers/jersey-container-simple-http

  1. @Override
  2. public void handle(final Request request, final Response response) {
  3. final ResponseWriter responseWriter = new ResponseWriter(response, scheduler);
  4. final URI baseUri = getBaseUri(request);
  5. final URI requestUri = getRequestUri(request, baseUri);
  6. try {
  7. final ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri,
  8. request.getMethod(), getSecurityContext(request), new MapPropertiesDelegate());
  9. requestContext.setEntityStream(request.getInputStream());
  10. for (final String headerName : request.getNames()) {
  11. requestContext.headers(headerName, request.getValue(headerName));
  12. }
  13. requestContext.setWriter(responseWriter);
  14. requestContext.setRequestScopedInitializer(injectionManager -> {
  15. injectionManager.<Ref<Request>>getInstance(RequestTYPE).set(request);
  16. injectionManager.<Ref<Response>>getInstance(ResponseTYPE).set(response);
  17. });
  18. appHandler.handle(requestContext);
  19. } catch (final Exception ex) {
  20. throw new RuntimeException(ex);
  21. } finally {
  22. if (!responseWriter.isSuspended()) {
  23. close(response);
  24. }
  25. }
  26. }

相关文章