Source:
public void getHttpResponse(HttpRequest httpRequest, Response coapResponse, HttpResponse httpResponse) throws TranslationException { if (httpRequest == null) { throw new IllegalArgumentException("httpRequest == null"); } if (coapResponse == null) { throw new IllegalArgumentException("coapResponse == null"); } if (httpResponse == null) { throw new IllegalArgumentException("httpResponse == null"); } ResponseCode coapCode = coapResponse.getCode(); String httpCodeString = httpTranslationProperties.getProperty(KEY_COAP_CODE + coapCode.value); if (httpCodeString == null || httpCodeString.isEmpty()) { LOGGER.warn("httpCodeString == null"); throw new TranslationException("httpCodeString == null"); } int httpCode = 0; try { httpCode = Integer.parseInt(httpCodeString.trim()); } catch (NumberFormatException e) { LOGGER.warn("Cannot convert the coap code in http status code {}", e); throw new TranslationException("Cannot convert the coap code in http status code", e); } String reason = EnglishReasonPhraseCatalog.INSTANCE.getReason(httpCode, Locale.ENGLISH); StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, httpCode, reason); httpResponse.setStatusLine(statusLine); Header[] headers = getHttpHeaders(coapResponse.getOptions().asSortedList()); httpResponse.setHeaders(headers); if (!httpResponse.containsHeader("cache-control")) { httpResponse.setHeader("cache-control", "max-age=" + Long.toString(OptionNumberRegistry.Defaults.MAX_AGE)); } if (!httpRequest.getRequestLine().getMethod().equalsIgnoreCase("head")) { if (coapResponse.getOptions().getContentFormat() == MediaTypeRegistry.UNDEFINED && (ResponseCode.isClientError(coapCode) || ResponseCode.isServerError(coapCode))) { LOGGER.info("Set contenttype to TEXT_PLAIN"); coapResponse.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); } HttpEntity httpEntity = getHttpEntity(coapResponse); if (httpEntity != null) { httpResponse.setEntity(httpEntity); ContentType contentType = ContentType.get(httpEntity); httpResponse.setHeader("content-type", contentType.toString()); } } }

Target:
public void getHttpResponse(HttpRequest httpRequest, Response coapResponse, HttpResponse httpResponse) throws TranslationException { if (httpRequest == null) { throw new IllegalArgumentException("httpRequest == null"); } if (coapResponse == null) { throw new IllegalArgumentException("coapResponse == null"); } if (httpResponse == null) { throw new IllegalArgumentException("httpResponse == null"); } ResponseCode coapCode = coapResponse.getCode(); String httpCodeString = httpTranslationProperties.getProperty(KEY_COAP_CODE + coapCode.value); if (httpCodeString == null || httpCodeString.isEmpty()) { LOGGER.warn("httpCodeString == null"); throw new TranslationException("httpCodeString == null"); } int httpCode = 0; try { httpCode = Integer.parseInt(httpCodeString.trim()); } catch (NumberFormatException e) { LOGGER.warn("Cannot convert the coap code in http status code", e); throw new TranslationException("Cannot convert the coap code in http status code", e); } String reason = EnglishReasonPhraseCatalog.INSTANCE.getReason(httpCode, Locale.ENGLISH); StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, httpCode, reason); httpResponse.setStatusLine(statusLine); Header[] headers = getHttpHeaders(coapResponse.getOptions().asSortedList()); httpResponse.setHeaders(headers); if (!httpResponse.containsHeader("cache-control")) { httpResponse.setHeader("cache-control", "max-age=" + Long.toString(OptionNumberRegistry.Defaults.MAX_AGE)); } if (!httpRequest.getRequestLine().getMethod().equalsIgnoreCase("head")) { if (coapResponse.getOptions().getContentFormat() == MediaTypeRegistry.UNDEFINED && (ResponseCode.isClientError(coapCode) || ResponseCode.isServerError(coapCode))) { LOGGER.info("Set contenttype to TEXT_PLAIN"); coapResponse.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); } HttpEntity httpEntity = getHttpEntity(coapResponse); if (httpEntity != null) { httpResponse.setEntity(httpEntity); ContentType contentType = ContentType.get(httpEntity); httpResponse.setHeader("content-type", contentType.toString()); } } }