コード例 #1
0
    @OnMessage
    public String getHeaders(Session session, String headerKey) {
      StringBuilder response = new StringBuilder();

      response.append("Request Header [").append(headerKey).append("]: ");
      @SuppressWarnings("unchecked")
      Map<String, List<String>> headers =
          (Map<String, List<String>>) session.getUserProperties().get("request-headers");
      if (headers == null) {
        response.append("<no headers found in session.getUserProperties()>");
      } else {
        List<String> values = headers.get(headerKey);
        if (values == null) {
          response.append("<header not found>");
        } else {
          response.append(QuoteUtil.join(values, ","));
        }
      }

      return response.toString();
    }