listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners()); listeners.addAll(lastExchange.getResponseListeners()); if (overrideListener != null) listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners());
listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners()); listeners.addAll(lastExchange.getResponseListeners()); if (overrideListener != null) listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners());
listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners()); listeners.addAll(lastExchange.getResponseListeners()); if (overrideListener != null) listeners.add(overrideListener); else listeners.addAll(firstExchange.getResponseListeners());
public void send() { HttpExchange exchange = getHttpExchange(); if (exchange != null) { HttpRequest request = exchange.getRequest(); long timeoutAt = request.getTimeoutAt(); if (timeoutAt != -1) { exchange.getResponseListeners().add(_totalTimeout); _totalTimeout.schedule(request, timeoutAt); } send(exchange); } }
@Override public void onFailure(Response response, Throwable failure) { HttpConversation conversation = client.getConversation(response.getConversationID(), false); // Mark the 100 Continue response as handled conversation.setAttribute(ATTRIBUTE, Boolean.TRUE); // Reset the conversation listeners to allow the conversation to be completed conversation.updateResponseListeners(null); HttpExchange exchange = conversation.getExchanges().peekLast(); assert exchange.getResponse() == response; List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getEncoding()); notifier.forwardFailureComplete(listeners, exchange.getRequest(), exchange.getRequestFailure(), contentResponse, failure); }
@Override public void onFailure(Response response, Throwable failure) { HttpConversation conversation = client.getConversation(response.getConversationID(), false); // Mark the 100 Continue response as handled conversation.setAttribute(ATTRIBUTE, Boolean.TRUE); // Reset the conversation listeners to allow the conversation to be completed conversation.updateResponseListeners(null); HttpExchange exchange = conversation.getExchanges().peekLast(); assert exchange.getResponse() == response; List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getEncoding()); notifier.forwardFailureComplete(listeners, exchange.getRequest(), exchange.getRequestFailure(), contentResponse, failure); }
@Override public void onFailure(Response response, Throwable failure) { HttpConversation conversation = ((HttpRequest)response.getRequest()).getConversation(); // Mark the 100 Continue response as handled conversation.setAttribute(ATTRIBUTE, Boolean.TRUE); // Reset the conversation listeners to allow the conversation to be completed conversation.updateResponseListeners(null); HttpExchange exchange = conversation.getExchanges().peekLast(); assert exchange.getResponse() == response; List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getMediaType(), getEncoding()); notifier.forwardFailureComplete(listeners, exchange.getRequest(), exchange.getRequestFailure(), contentResponse, failure); }
List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getEncoding()); notifier.forwardSuccess(listeners, contentResponse);
List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getEncoding()); notifier.forwardSuccess(listeners, contentResponse);
@Override public void onSuccess(Response response) { // Handling of success must be done here and not from onComplete(), // since the onComplete() is not invoked because the request is not completed yet. Request request = response.getRequest(); HttpConversation conversation = ((HttpRequest)request).getConversation(); // Mark the 100 Continue response as handled request.attribute(ATTRIBUTE, Boolean.TRUE); // Reset the conversation listeners, since we are going to receive another response code conversation.updateResponseListeners(null); HttpExchange exchange = conversation.getExchanges().peekLast(); if (response.getStatus() == HttpStatus.CONTINUE_100) { // All good, continue. exchange.resetResponse(); exchange.proceed(null); onContinue(request); } else { // Server either does not support 100 Continue, // or it does and wants to refuse the request content, // or we got some other HTTP status code like a redirect. List<Response.ResponseListener> listeners = exchange.getResponseListeners(); HttpContentResponse contentResponse = new HttpContentResponse(response, getContent(), getMediaType(), getEncoding()); notifier.forwardSuccess(listeners, contentResponse); exchange.proceed(new HttpRequestException("Expectation failed", request)); } }