List of usage examples for io.vertx.core.http HttpHeaders ETAG
CharSequence ETAG
To view the source code for io.vertx.core.http HttpHeaders ETAG.
Click Source Link
From source file:com.github.ithildir.airbot.service.impl.AirNowMeasurementServiceImpl.java
License:Open Source License
@Override public void init(Handler<AsyncResult<Void>> handler) { if (StringUtils.isBlank(_reportingAreaETag)) { _initReportingAreaRecords(handler); return;//w ww .j ava 2s . c o m } HttpRequest<?> httpRequest = _webClient.head(_REPORTING_AREA_URI); httpRequest = httpRequest.as(BodyCodec.none()); httpRequest.send(asyncResult -> { HttpResponse<?> httpResponse = _handleHttpResponse(asyncResult, handler); if (httpResponse == null) { return; } String etag = httpResponse.getHeader(HttpHeaders.ETAG.toString()); if (_reportingAreaETag.equals(etag)) { if (_logger.isDebugEnabled()) { _logger.debug("AirNow reporting area records are already " + "up-to-date with ETag {0}", etag); } return; } _initReportingAreaRecords(handler); }); }
From source file:com.github.ithildir.airbot.service.impl.AirNowMeasurementServiceImpl.java
License:Open Source License
private void _initReportingAreaRecords(Handler<AsyncResult<Void>> handler) { HttpRequest<?> httpRequest = _webClient.get(_REPORTING_AREA_URI); RecordParser recordParser = RecordParser.newDelimited("\n", this::_initReportingAreaRecord); httpRequest = httpRequest.as(BodyCodec.pipe(new RecordParserWriteStream(recordParser))); httpRequest.send(asyncResult -> { HttpResponse<?> httpResponse = _handleHttpResponse(asyncResult, handler); if (httpResponse == null) { return; }//from w ww .j a va2 s .com _reportingAreaETag = httpResponse.getHeader(HttpHeaders.ETAG.toString()); if (_logger.isInfoEnabled()) { _logger.info("AirNow reporting area records updated with ETag {0}", _reportingAreaETag); } handler.handle(Future.succeededFuture()); }); }