org.eclipse.californium.core.coap.Request.getURI()方法的使用及代码示例

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

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

Request.getURI介绍

[英]Gets a URI derived from this request's options and properties as defined by RFC 7252, Section 6.5.

This method falls back to using localhost as the host part in the returned URI if both the destination as well as the Uri-Host option are null(mostly when receiving a request without a Uri-Host option).
[中]获取从RFC 7252, Section 6.5定义的此请求的选项和属性派生的URI。
如果destinationURI host选项都为空(主要是在接收不带URI host选项的请求时),此方法会退回使用localhost作为返回URI中的主机部分。

代码示例

代码示例来源:origin: eclipse/leshan

@Override
public void onReject() {
  exception.set(new RequestRejectedException("Request %s rejected", coapRequest.getURI()));
  latch.countDown();
}

代码示例来源:origin: org.github.leshan/leshan-client

public OperationResponse waitForResponse() {
    try {
      final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS);
      if (!latchTimeout || coapTimeout.get()) {
        coapRequest.cancel();
        if (exception.get() != null) {
          throw exception.get();
        } else {
          throw new RuntimeException("Request Timed Out: " + coapRequest.getURI() + " (timeout)");
        }
      }
    } catch (final InterruptedException e) {
      // no idea why some other thread should have interrupted this thread
      // but anyway, go ahead as if the timeout had been reached
      LOG.info("Caught an unexpected InterruptedException during execution of CoAP request " + e);
    } finally {
      coapRequest.removeMessageObserver(this);
    }
    if (exception.get() != null) {
      throw exception.get();
    }
    return ref.get();
  }
}

代码示例来源:origin: org.eclipse.leshan/leshan-client

public OperationResponse waitForResponse() {
    try {
      final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS);
      if (!latchTimeout || coapTimeout.get()) {
        coapRequest.cancel();
        if (exception.get() != null) {
          throw exception.get();
        } else {
          throw new RuntimeException("Request Timed Out: " + coapRequest.getURI() + " (timeout)");
        }
      }
    } catch (final InterruptedException e) {
      // no idea why some other thread should have interrupted this thread
      // but anyway, go ahead as if the timeout had been reached
      LOG.info("Caught an unexpected InterruptedException during execution of CoAP request " + e);
    } finally {
      coapRequest.removeMessageObserver(this);
    }
    if (exception.get() != null) {
      throw exception.get();
    }
    return ref.get();
  }
}

代码示例来源:origin: eclipse/leshan

@Override
public void onCancel() {
  cancelCleaningTask();
  if (responseTimedOut.get())
    errorCallback.onError(new org.eclipse.leshan.core.request.exception.TimeoutException("Request %s timed out",
        coapRequest.getURI()));
  else
    errorCallback.onError(new RequestCanceledException("Request %s cancelled", coapRequest.getURI()));
}

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

public T waitForResponse() {
    try {
      final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS);
      if (!latchTimeout || coapTimeout.get()) {
        clientRegistry.deregisterClient(client.getRegistrationId());
        coapRequest.cancel();
        if (exception.get() != null) {
          throw exception.get();
        } else {
          throw new RequestTimeoutException(coapRequest.getURI(), timeout);
        }
      }
    } catch (final InterruptedException e) {
      // no idea why some other thread should have interrupted this thread
      // but anyway, go ahead as if the timeout had been reached
      LOG.debug("Caught an unexpected InterruptedException during execution of CoAP request", e);
    } finally {
      coapRequest.removeMessageObserver(this);
    }
    if (exception.get() != null) {
      throw exception.get();
    }
    return ref.get();
  }
}

代码示例来源:origin: eclipse/leshan

@Override
public void onReject() {
  cancelCleaningTask();
  errorCallback.onError(new RequestRejectedException("Request %s rejected", coapRequest.getURI()));
}

代码示例来源:origin: eclipse/leshan

@Override
public void onSendError(Throwable error) {
  cancelCleaningTask();
  errorCallback.onError(new SendFailedException(error, "Unable to send request %s", coapRequest.getURI()));
}

代码示例来源:origin: eclipse/leshan

@Override
public void onTimeout() {
  cancelCleaningTask();
  errorCallback.onError(new org.eclipse.leshan.core.request.exception.TimeoutException("Request %s timed out",
      coapRequest.getURI()));
}

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

/**
   * Throws a generic {@link ResourceAccessException} indicating that the client returned an unexpected response code.
   *
   * @param request
   * @param coapRequest
   * @param coapResponse
   */
  private void handleUnexpectedResponseCode(final String clientEndpoint, final Request coapRequest,
      final Response coapResponse) {
    final String msg = String.format("Client [%s] returned unexpected response code [%s]", clientEndpoint,
        coapResponse.getCode());
    throw new ResourceAccessException(fromCoapCode(coapResponse.getCode().value), coapRequest.getURI(), msg);
  }
}

代码示例来源:origin: eclipse/californium

/**
 * Verifies that a URI composed from options contains the literal destination IP address if
 * no Uri-Host option value is set.
 */
@Test
public void testGetURIContainsLiteralIpAddressDestination() {
  Request req = Request.newGet().setURI("coap://192.168.0.1:12000");
  URI uri = URI.create(req.getURI());
  assertThat(uri.getHost(), is("192.168.0.1"));
}

代码示例来源:origin: eclipse/californium

/**
 * Verifies that a URI without "path" and "query part" is well formed.
 */
@Test
public void testGetURIWithoutPathAndQuery() {
  Request req = Request.newGet().setURI("coap://192.168.0.1:12000");
  String uri = req.getURI();
  assertThat(uri, is("coap://192.168.0.1:12000/"));
}

代码示例来源:origin: eclipse/californium

/**
 * Verifies that the getURI method escapes non-ASCII characters contained in path and query.
 * @throws UnknownHostException 
 */
@Test
public void testGetURIEscapesNonAsciiCharacters() throws UnknownHostException {
  Request req = Request.newGet().setURI("coap://192.168.0.1");
  req.getOptions().addUriPath("non-ascii-path-äöü").addUriQuery("non-ascii-query=äöü");
  String derivedUri = req.getURI();
  System.out.println(derivedUri);
  URI uri = URI.create(derivedUri);
  assertThat(uri.getRawPath(), is("/non-ascii-path-%C3%A4%C3%B6%C3%BC"));
  assertThat(uri.getRawQuery(), is("non-ascii-query=%C3%A4%C3%B6%C3%BC"));
}

代码示例来源:origin: eclipse/californium

/**
 * Verifies that a URI with "path" and without "query part" is well formed.
 */
@Test
public void testGetURIWithPathAndWithoutQuery() {
  Request req = Request.newGet().setURI("coap://192.168.0.1:12000/30/40");
  String uri = req.getURI();
  assertThat(uri, is("coap://192.168.0.1:12000/30/40"));
}

代码示例来源:origin: eclipse/californium

/**
 * Verifies that a URI without "path" and with "query part" is well formed.
 */
@Test
public void testGetURIWithoutPathAndWithQuery() {
  Request req = Request.newGet().setURI("coap://192.168.0.1:12000?parameter");
  String uri = req.getURI();
  assertThat(uri, is("coap://192.168.0.1:12000/?parameter"));
}

代码示例来源:origin: eclipse/californium

Exchange.KeyUri idByUri = new Exchange.KeyUri(request.getURI(), response.getDestination().getAddress(),
    response.getDestinationPort());

代码示例来源:origin: eclipse/californium

return exchange;
} else {
  Exchange.KeyUri idByUri = new Exchange.KeyUri(request.getURI(), request.getSource().getAddress(),
      request.getSourcePort());
  LOGGER.log(Level.FINE, "Looking up ongoing exchange for {0}", idByUri);

代码示例来源:origin: org.eclipse.californium/californium-core

KeyUri idByUri = new KeyUri(request.getURI(), response.getDestination().getAddress(), response.getDestinationPort());

代码示例来源:origin: eclipse/californium

request.getOptions().setProxyUri(request.getURI());
LOGGER.info("Local request to " + request.getURI());
List<String> path = request.getOptions().getUriPath();
resource = findResource(path);

代码示例来源:origin: eclipse/californium

Exchange.KeyUri uriKey = new Exchange.KeyUri(request.getURI(), request.getSource().getAddress(),
    request.getSourcePort());
LOGGER.log(Level.FINE, "Remote ongoing completed, cleaning up ", uriKey);

代码示例来源:origin: eclipse/californium

KeyUri idByUri = new KeyUri(request.getURI(), response.getDestination().getAddress(),
    response.getDestinationPort());

相关文章

微信公众号

最新文章

更多