org.restlet.Response.getRequest()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(155)

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

Response.getRequest介绍

[英]Returns the associated request
[中]返回关联的请求

代码示例

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

@Override
public boolean isConfidential() {
  return getRequest().isConfidential();
}

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

/**
 * Ask the connector to abort the related network connection, for example
 * immediately closing the socket.
 */
public void abort() {
  getRequest().abort();
}

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

/**
   * Displays a synthesis of the response like an HTTP status line.
   * 
   * @return A synthesis of the response like an HTTP status line.
   */
  public String toString() {
    return ((getRequest() == null) ? "?" : getRequest().getProtocol())
        + " - " + getStatus();
  }
}

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

/**
 * Asks the server connector to immediately flush the network buffers. Note
 * that this calls back {@link Request#flushBuffers()} on the parent request
 * which holds the link with the underlying network connection.
 * 
 * @throws IOException
 */
@Override
public void flushBuffers() throws IOException {
  getRequest().flushBuffers();
}

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

/**
 * Returns the associated request
 * 
 * @return The associated request
 */
@Override
public Request getRequest() {
  return getWrappedResponse().getRequest();
}

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      cfg.getTemplate( "links.htm" ).process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<String, Object>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      template.process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      cfg.getTemplate( "links.atom" ).process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      cfg.getTemplate( "form.htm" ).process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

代码示例来源:origin: apache/attic-polygene-java

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      cfg.getTemplate( "table.htm" ).process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

@Override
  public void write( Writer writer )
    throws IOException
  {
    Map<String, Object> context = new HashMap<>();
    context.put( "request", response.getRequest() );
    context.put( "response", response );
    context.put( "result", result );
    try
    {
      cfg.getTemplate( "table.htm" ).process( context, writer );
    }
    catch( TemplateException e )
    {
      throw new IOException( e );
    }
  }
};

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

/**
 * Asks the server connector to immediately commit the given response,
 * making it ready to be sent back to the client. Note that all server
 * connectors don't necessarily support this feature.<br>
 * <br>
 * When the response is in autoCommit mode (see related property), then
 * calling this method isn't necessary. Also, be aware that committing the
 * response doesn't necessarily means that is will be immediately be written
 * on the network as some buffering can occurs. If you want to ensure that
 * response buffers are flushed,<br>
 * <br>
 * Note that this calls back {@link Request#commit(Response)} on the parent
 * request which holds the link with the underlying network connection.
 */
public void commit() {
  getRequest().commit(this);
}

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

/**
 * Returns the request associated to the current thread. This is reusing the {@link Response#getCurrent()} method.<br>
 * <br>
 * Warning: this method should only be used under duress. You should by
 * default prefer obtaining the current context using methods such as
 * {@link org.restlet.resource.Resource#getRequest()}.
 * 
 * @return The thread's request.
 */
public static Request getCurrent() {
  return (Response.getCurrent() == null) ? null : Response.getCurrent()
      .getRequest();
}

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

/**
 * Format an access log entry. If the log template property isn't provided,
 * then a default IIS like format is used.
 * 
 * @param response
 *            The response to log.
 * @param duration
 *            The call duration.
 * @return The formatted log entry.
 */
public String getResponseLogMessage(Response response, int duration) {
  String result = null;
  // Format the call into a log entry
  if (this.responseLogTemplate != null) {
    result = this.responseLogTemplate.format(response.getRequest(),
        response);
  } else {
    result = getDefaultResponseLogMessage(response, duration);
  }
  return result;
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
public void challenge(Response response, boolean stale) {
  // Load the FreeMarker template
  Representation ftl = new ClientResource(
      LocalReference.createClapReference(getClass().getPackage())
          + "/Login.ftl").get();
  // Wraps the bean with a FreeMarker representation
  response.setEntity(new TemplateRepresentation(ftl, response
      .getRequest().getResourceRef(), MediaType.TEXT_HTML));
  response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

@Override
public void challenge(Response response, boolean stale) {
  // Load the FreeMarker template
  Representation ftl = new ClientResource(
      LocalReference.createClapReference(getClass().getPackage())
          + "/Login.ftl").get();
  // Wraps the bean with a FreeMarker representation
  response.setEntity(new TemplateRepresentation(ftl, response
      .getRequest().getResourceRef(), MediaType.TEXT_HTML));
  response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
}

代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server

@Override
  public boolean writeResponse( final Object result, final Response response )
    throws ResourceException
  {
    MediaType type = getVariant( response.getRequest(), ENGLISH, supportedMediaTypes ).getMediaType();
    if( MediaType.APPLICATION_JSON.equals( type ) )
    {
      if( result instanceof String || result instanceof Number || result instanceof Boolean )
      {
        StringRepresentation representation = new StringRepresentation( result.toString(),
                                        MediaType.APPLICATION_JSON );

        response.setEntity( representation );

        return true;
      }
    }

    return false;
  }
}

代码示例来源:origin: apache/attic-polygene-java

@Override
  public boolean writeResponse( final Object result, final Response response )
    throws ResourceException
  {
    MediaType type = getVariant( response.getRequest(), ENGLISH, supportedMediaTypes ).getMediaType();
    if( MediaType.APPLICATION_JSON.equals( type ) )
    {
      if( result instanceof String || result instanceof Number || result instanceof Boolean )
      {
        StringRepresentation representation = new StringRepresentation( result.toString(),
                                        MediaType.APPLICATION_JSON );

        response.setEntity( representation );

        return true;
      }
    }

    return false;
  }
}

代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server

@Override
  public boolean writeResponse( final Object result, final Response response )
    throws ResourceException
  {
    MediaType type = getVariant( response.getRequest(), ENGLISH, supportedMediaTypes ).getMediaType();
    if( MediaType.APPLICATION_JSON.equals( type ) )
    {
      if( result instanceof String || result instanceof Number || result instanceof Boolean )
      {
        StringRepresentation representation = new StringRepresentation( result.toString(),
                                        MediaType.APPLICATION_JSON );

        response.setEntity( representation );

        return true;
      }
    }

    return false;
  }
}

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

@Override
public Representation handleInbound(Response response) {
  Representation result = null;
  // Verify that the request was synchronous
  if (response.getRequest().isSynchronous()) {
    if (response.getStatus().isError()) {
      doError(response.getStatus());
      // DO NOT DISPOSE THE RESPONSE.
    }/* else { */
    result = (response == null) ? null : response.getEntity();
    /* } */
  }
  return result;
}

相关文章