List of usage examples for io.netty.handler.codec.http HttpResponseStatus parseLine
public static HttpResponseStatus parseLine(AsciiString line)
From source file:com.turo.pushy.apns.ApnsClientHandler.java
License:Open Source License
private void handleEndOfStream(final ChannelHandlerContext context, final Http2Stream stream, final Http2Headers headers, final ByteBuf data) { final PushNotificationPromise<ApnsPushNotification, PushNotificationResponse<ApnsPushNotification>> responsePromise = stream .getProperty(this.responsePromisePropertyKey); final ApnsPushNotification pushNotification = responsePromise.getPushNotification(); final HttpResponseStatus status = HttpResponseStatus.parseLine(headers.status()); if (HttpResponseStatus.OK.equals(status)) { responsePromise.trySuccess(new SimplePushNotificationResponse<>(responsePromise.getPushNotification(), true, getApnsIdFromHeaders(headers), null, null)); } else {/*from w w w . j a v a 2 s . c om*/ if (data != null) { final ErrorResponse errorResponse = GSON.fromJson(data.toString(StandardCharsets.UTF_8), ErrorResponse.class); this.handleErrorResponse(context, stream.id(), headers, pushNotification, errorResponse); } else { log.warn("Gateway sent an end-of-stream HEADERS frame for an unsuccessful notification."); } } }
From source file:com.turo.pushy.apns.ApnsClientHandler.java
License:Open Source License
protected void handleErrorResponse(final ChannelHandlerContext context, final int streamId, final Http2Headers headers, final ApnsPushNotification pushNotification, final ErrorResponse errorResponse) { final PushNotificationPromise<ApnsPushNotification, PushNotificationResponse<ApnsPushNotification>> responsePromise = this .connection().stream(streamId).getProperty(this.responsePromisePropertyKey); final HttpResponseStatus status = HttpResponseStatus.parseLine(headers.status()); responsePromise.trySuccess(new SimplePushNotificationResponse<>(responsePromise.getPushNotification(), HttpResponseStatus.OK.equals(status), getApnsIdFromHeaders(headers), errorResponse.getReason(), errorResponse.getTimestamp())); }