org.restlet.Request.getClientInfo()方法的使用及代码示例

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

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

Request.getClientInfo介绍

[英]Returns the client-specific information. Creates a new instance if no one has been set.
[中]返回特定于客户端的信息。如果未设置任何实例,则创建新实例。

代码示例

代码示例来源:origin: stackoverflow.com

Filter preferencesFilter = new Filter(getContext()) {
  protected int beforeHandle(Request request, Response response) {
    if (request.getClientInfo().getAcceptedMediaTypes().isEmpty()) {
      request.getClientInfo().accept(MediaType.APPLICATION_JSON);
    } else if ((request.getClientInfo().getAcceptedMediaTypes().size() == 1)
      && (request.getClientInfo().getAcceptedMediaTypes().get(0).getMetadata().equals(MediaType.ALL))) {
      request.getClientInfo().accept(MediaType.APPLICATION_JSON);
    }
    return super.beforeHandle(request, response);
  }            
}

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

/**
 * Returns the client-specific information.
 * 
 * @return The client-specific information.
 */
@Override
public ClientInfo getClientInfo() {
  return getWrappedRequest().getClientInfo();
}

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

@Override
public String getCountedValue(Request request) {
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  if (request.getClientInfo().getUser() != null) {
    return request.getClientInfo().getUser().getIdentifier();
  }
  // Otherwise, use the IP address.
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  if (request.getClientInfo().getUser() != null) {
    return request.getClientInfo().getUser().getIdentifier();
  }
  // Otherwise, use the IP address.
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  if (request.getClientInfo().getUser() != null) {
    return request.getClientInfo().getUser().getIdentifier();
  }
  // Otherwise, use the IP address.
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  if (request.getClientInfo().getUser() != null) {
    return request.getClientInfo().getUser().getIdentifier();
  }
  // Otherwise, use the IP address.
  return request.getClientInfo().getUpstreamAddress();
}

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

@Override
public String getCountedValue(Request request) {
  if (request.getClientInfo().getUser() != null) {
    return request.getClientInfo().getUser().getIdentifier();
  }
  // Otherwise, use the IP address.
  return request.getClientInfo().getUpstreamAddress();
}

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

/**
 * Returns the enriched list of language preferences.
 * 
 * @return The enriched list of language preferences.
 */
protected List<Preference<Language>> getLanguagePrefs() {
  return getRequest().getClientInfo().getAcceptedLanguages();
}

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

/**
 * Returns the enriched list of media type preferences.
 * 
 * @return The enriched list of media type preferences.
 */
protected List<Preference<MediaType>> getMediaTypePrefs() {
  return getRequest().getClientInfo().getAcceptedMediaTypes();
}

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

/**
 * Returns the enriched list of character set preferences.
 * 
 * @return The enriched list of character set preferences.
 */
protected List<Preference<CharacterSet>> getCharacterSetPrefs() {
  return getRequest().getClientInfo().getAcceptedCharacterSets();
}

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

/**
 * Returns the enriched list of encoding preferences.
 * 
 * @return The enriched list of encoding preferences.
 */
protected List<Preference<Encoding>> getEncodingPrefs() {
  return getRequest().getClientInfo().getAcceptedEncodings();
}

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

@Override
public void handle(Request request, Response response) {
  String entity = "Method       : " + request.getMethod()
      + "\nResource URI : " + request.getResourceRef()
      + "\nIP address   : " + request.getClientInfo().getAddress()
      + "\nAgent name   : " + request.getClientInfo().getAgentName()
      + "\nAgent version: "
      + request.getClientInfo().getAgentVersion();
  response.setEntity(entity, MediaType.TEXT_PLAIN);
}

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

@Override
public void handle(Request request, Response response) {
  String entity = "Method       : " + request.getMethod()
      + "\nResource URI : " + request.getResourceRef()
      + "\nIP address   : " + request.getClientInfo().getAddress()
      + "\nAgent name   : " + request.getClientInfo().getAgentName()
      + "\nAgent version: "
      + request.getClientInfo().getAgentVersion();
  response.setEntity(entity, MediaType.TEXT_PLAIN);
}

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

/**
 * Returns the client-specific information. Creates a new instance if no one
 * has been set.
 * 
 * @return The client-specific information.
 * @see Request#getClientInfo()
 */
public ClientInfo getClientInfo() {
  return getRequest() == null ? null : getRequest().getClientInfo();
}

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

@Override
  public void handle(Request request, Response response) {
    String entity = "Method       : " + request.getMethod()
        + "\nResource URI : " + request.getResourceRef()
        + "\nIP address   : "
        + request.getClientInfo().getAddress()
        + "\nAgent name   : "
        + request.getClientInfo().getAgentName()
        + "\nAgent version: "
        + request.getClientInfo().getAgentVersion();
    response.setEntity(entity, MediaType.TEXT_PLAIN);
  }
};

代码示例来源:origin: com.github.ansell.oas/oas-webservice-impl

@Get
public Representation getIndexPageHtml(final Representation entity) throws ResourceException
{
  this.checkAuthentication(BaseOasActions.WHOAMI_CHECK);
  
  Representation result = null;
  
  if(this.getRequest().getClientInfo().isAuthenticated())
  {
    result = new StringRepresentation(this.getRequest().getClientInfo().getUser().getIdentifier());
  }
  
  return result;
}

相关文章