public void updateStatistics(Request request, boolean cachedResponse) { URI proxyUri = null; try { proxyUri = new URI(request.getOptions().getProxyUri()); } catch (URISyntaxException e) { LOGGER.warning(String.format("Proxy-uri malformed: %s", request.getOptions().getProxyUri()));
public void updateStatistics(Request request, boolean cachedResponse) { URI proxyUri = null; try { proxyUri = new URI(request.getOptions().getProxyUri()); } catch (URISyntaxException e) { LOGGER.warning(String.format("Proxy-uri malformed: %s", request.getOptions().getProxyUri()));
/** * Manage proxy uri request. * * @param request * the request * @throws URISyntaxException * the uRI syntax exception */ private void manageProxyUriRequest(Request request) throws URISyntaxException { // check which schema is requested URI proxyUri = new URI(request.getOptions().getProxyUri()); // the local resource that will abstract the client part of the // proxy String clientPath; // switch between the schema requested if (proxyUri.getScheme() != null && proxyUri.getScheme().matches("^http.*")) { // the local resource related to the http client clientPath = PROXY_HTTP_CLIENT; } else { // the local resource related to the http client clientPath = PROXY_COAP_CLIENT; } LOGGER.info("Chose "+clientPath+" as clientPath"); // set the path in the request to be forwarded correctly request.getOptions().setUriPath(clientPath); }
String proxyUri = request.getOptions().getProxyUri(); try {
String proxyUri = request.getOptions().getProxyUri(); try {
String proxyUriString = URLDecoder.decode(incomingCoapRequest.getOptions().getProxyUri(), "UTF-8"); proxyUri = new URI(proxyUriString); } catch (UnsupportedEncodingException e) {
try { String proxyUriString = URLDecoder.decode( incomingCoapRequest.getOptions().getProxyUri(), "UTF-8"); proxyUri = new URI(proxyUriString); } catch (UnsupportedEncodingException e) {
/** * Create a key for the cache starting from a request and the * content-type of the corresponding response. * * @param request * @return * @throws URISyntaxException */ private static CacheKey fromContentTypeOption(Request request) throws URISyntaxException { if (request == null) { throw new IllegalArgumentException("request == null"); } Response response = request.getResponse(); if (response == null) { return fromAcceptOptions(request).get(0); } String proxyUri = request.getOptions().getProxyUri(); int mediaType = response.getOptions().getContentFormat(); if (mediaType < 0) { // content-format option not set, use default mediaType = MediaTypeRegistry.TEXT_PLAIN; } byte[] payload = request.getPayload(); // create the new cacheKey CacheKey cacheKey = new CacheKey(proxyUri, mediaType, payload); cacheKey.setResponse(response); return cacheKey; }
/** * Create a key for the cache starting from a request and the * content-type of the corresponding response. * * @param request * @return * @throws URISyntaxException */ private static CacheKey fromContentTypeOption(Request request) throws URISyntaxException { if (request == null) { throw new IllegalArgumentException("request == null"); } Response response = request.getResponse(); if (response == null) { return fromAcceptOptions(request).get(0); } String proxyUri = request.getOptions().getProxyUri(); int mediaType = response.getOptions().getContentFormat(); if (mediaType < 0) { // content-format option not set, use default mediaType = MediaTypeRegistry.TEXT_PLAIN; } byte[] payload = request.getPayload(); // create the new cacheKey CacheKey cacheKey = new CacheKey(proxyUri, mediaType, payload); cacheKey.setResponse(response); return cacheKey; }
options.add(new Option(OptionNumberRegistry.LOCATION_QUERY, str)); if (hasProxyUri()) options.add(new Option(OptionNumberRegistry.PROXY_URI, getProxyUri())); if (hasProxyScheme()) options.add(new Option(OptionNumberRegistry.PROXY_SCHEME, getProxyScheme()));
options.add(new Option(OptionNumberRegistry.LOCATION_QUERY, str)); if (hasProxyUri()) options.add(new Option(OptionNumberRegistry.PROXY_URI, getProxyUri())); if (hasProxyScheme()) options.add(new Option(OptionNumberRegistry.PROXY_SCHEME, getProxyScheme()));
coapRequest.getOptions().getProxyUri(), "UTF-8"); proxyUri = new URI(proxyUriString); } catch (UnsupportedEncodingException e) {
coapRequest.getOptions().getProxyUri(), "UTF-8"); proxyUri = new URI(proxyUriString); } catch (UnsupportedEncodingException e) {
LOGGER.warning(String.format("Proxy-uri malformed: %s", request.getOptions().getProxyUri()));
incomingRequest.getOptions().getProxyUri(), "UTF-8"); serverUri = new URI(proxyUriString); } catch (UnsupportedEncodingException e) {
try { String proxyUriString = URLDecoder.decode(incomingRequest.getOptions().getProxyUri(), "UTF-8"); serverUri = new URI(proxyUriString);
if (request.getOptions().getProxyUri().startsWith("http")) { resource = coap2http; } else {