Examples of FixedLengthStreamSinkConduit


Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

        // Create the channel and wrappers
        StreamSinkConduit conduit = new StreamSinkChannelWrappingConduit(underlyingChannel);
        conduit = new HttpRequestConduit(conduit, connection.getBufferPool(), request);
        if(! hasContent) {
            headers.put(Headers.CONTENT_LENGTH, 0L);
            conduit = new FixedLengthStreamSinkConduit(conduit, 0L, false, ! keepAlive, sendCompletedListener(request));
        } else {
            if (! Headers.IDENTITY.equals(transferEncoding)) {
                headers.put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString());
                conduit = new ChunkedStreamSinkConduit(conduit, false, ! keepAlive, sendCompletedListener(request), this);
            } else {
                if(contentLength == -1L) {
                    conduit = new FinishableStreamSinkConduit(conduit, sendCompletedListener(request));
                } else {
                    headers.put(Headers.CONTENT_LENGTH, contentLength);
                    conduit = new FixedLengthStreamSinkConduit(conduit, contentLength, false, ! keepAlive, sendCompletedListener(request));
                }
            }
        }
        conduitChannel = new ConduitStreamSinkChannel(underlyingChannel, conduit);
        requestChannel = new GatedStreamSinkChannel(conduitChannel, this, false, true);
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

                        // add least for websocket upgrades we can have a content length
                        final long contentLength;
                        try {
                            contentLength = Long.parseLong(contentLengthHeader);
                            // fixed-length response
                            wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                        } catch (NumberFormatException e) {
                            // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                            stillPersistent = false;
                            wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                        }
                    } else {
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, 0L, true, !stillPersistent, finishListener);
                    }
                } else if (!transferEncoding.equals(Headers.IDENTITY)) {
                    final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                    wrappedConduit = new ChunkedStreamSinkConduit(channel, true, !stillPersistent, finishListener, exchange);
                } else if (contentLengthHeader != null) {
                    final long contentLength;
                    try {
                        contentLength = Long.parseLong(contentLengthHeader);
                        final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                        // fixed-length response
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                    } catch (NumberFormatException e) {
                        // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                        stillPersistent = false;
                        wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                    }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

        // Create the channel and wrappers
        StreamSinkConduit conduit = new StreamSinkChannelWrappingConduit(underlyingChannel);
        conduit = new HttpRequestConduit(conduit, connection.getBufferPool(), request);
        if(! hasContent) {
            headers.put(Headers.CONTENT_LENGTH, 0L);
            conduit = new FixedLengthStreamSinkConduit(conduit, 0L, false, ! keepAlive, sendCompletedListener(request));
        } else {
            if (! Headers.IDENTITY.equals(transferEncoding)) {
                headers.put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString());
                conduit = new ChunkedStreamSinkConduit(conduit, false, ! keepAlive, sendCompletedListener(request), this);
            } else {
                if(contentLength == -1L) {
                    conduit = new FinishableStreamSinkConduit(conduit, sendCompletedListener(request));
                } else {
                    headers.put(Headers.CONTENT_LENGTH, contentLength);
                    conduit = new FixedLengthStreamSinkConduit(conduit, contentLength, false, ! keepAlive, sendCompletedListener(request));
                }
            }
        }
        conduitChannel = new ConduitStreamSinkChannel(underlyingChannel, conduit);
        requestChannel = new GatedStreamSinkChannel(conduitChannel, this, false, true);
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

                        // add least for websocket upgrades we can have a content length
                        final long contentLength;
                        try {
                            contentLength = Long.parseLong(contentLengthHeader);
                            // fixed-length response
                            wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                        } catch (NumberFormatException e) {
                            // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                            stillPersistent = false;
                            wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                        }
                    } else {
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, 0L, true, !stillPersistent, finishListener);
                    }
                } else if (!transferEncoding.equals(Headers.IDENTITY)) {
                    final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                    wrappedConduit = new ChunkedStreamSinkConduit(channel, true, !stillPersistent, finishListener, exchange);
                } else if (contentLengthHeader != null) {
                    final long contentLength;
                    try {
                        contentLength = Long.parseLong(contentLengthHeader);
                        final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                        // fixed-length response
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                    } catch (NumberFormatException e) {
                        // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                        stillPersistent = false;
                        wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                    }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

        // Create the channel and wrappers
        StreamSinkConduit conduit = new StreamSinkChannelWrappingConduit(underlyingChannel);
        conduit = new HttpRequestConduit(conduit, connection.getBufferPool(), request);
        if(! hasContent) {
            headers.put(Headers.CONTENT_LENGTH, 0L);
            conduit = new FixedLengthStreamSinkConduit(conduit, 0L, false, ! keepAlive, sendCompletedListener(request));
        } else {
            if (! Headers.IDENTITY.equals(transferEncoding)) {
                headers.put(Headers.TRANSFER_ENCODING, Headers.CHUNKED.toString());
                conduit = new ChunkedStreamSinkConduit(conduit, false, ! keepAlive, sendCompletedListener(request), this);
            } else {
                if(contentLength == -1L) {
                    conduit = new FinishableStreamSinkConduit(conduit, sendCompletedListener(request));
                } else {
                    headers.put(Headers.CONTENT_LENGTH, contentLength);
                    conduit = new FixedLengthStreamSinkConduit(conduit, contentLength, false, ! keepAlive, sendCompletedListener(request));
                }
            }
        }
        conduitChannel = new ConduitStreamSinkChannel(underlyingChannel, conduit);
        requestChannel = new GatedStreamSinkChannel(conduitChannel, this, false, true);
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

                        // add least for websocket upgrades we can have a content length
                        final long contentLength;
                        try {
                            contentLength = Long.parseLong(contentLengthHeader);
                            // fixed-length response
                            wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                        } catch (NumberFormatException e) {
                            // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                            stillPersistent = false;
                            wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                        }
                    } else {
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, 0L, true, !stillPersistent, finishListener);
                    }
                } else if (!transferEncoding.equals(Headers.IDENTITY)) {
                    final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                    wrappedConduit = new ChunkedStreamSinkConduit(channel, true, !stillPersistent, finishListener, exchange);
                } else if (contentLengthHeader != null) {
                    final long contentLength;
                    try {
                        contentLength = Long.parseLong(contentLengthHeader);
                        final ConduitListener<StreamSinkConduit> finishListener = stillPersistent ? terminateResponseListener(exchange) : null;
                        // fixed-length response
                        wrappedConduit = new FixedLengthStreamSinkConduit(channel, contentLength, true, !stillPersistent, finishListener);
                    } catch (NumberFormatException e) {
                        // assume that the response is unbounded, but forbid persistence (this will cause subsequent requests to fail when they write their replies)
                        stillPersistent = false;
                        wrappedConduit = new FinishableStreamSinkConduit(channel, terminateResponseListener(exchange));
                    }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

            final String contentLengthHeader = responseHeaders.getFirst(Headers.CONTENT_LENGTH);
            if (contentLengthHeader != null) {
                try {
                    final long contentLength = Long.parseLong(contentLengthHeader);
                    // fixed-length response
                    return new FixedLengthStreamSinkConduit(channel, contentLength, true, !exchange.isPersistent(), finishListener);
                } catch (NumberFormatException e) {
                    //we just fix it for them
                    responseHeaders.remove(Headers.CONTENT_LENGTH);
                }
            }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

                    final long contentLength = Long.parseLong(contentLengthHeader);
                    if(headRequest) {
                        return channel;
                    }
                    // fixed-length response
                    return new FixedLengthStreamSinkConduit(channel, contentLength, true, !exchange.isPersistent(), finishListener);
                } catch (NumberFormatException e) {
                    //we just fix it for them
                    responseHeaders.remove(Headers.CONTENT_LENGTH);
                }
            }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

                    final long contentLength = Long.parseLong(contentLengthHeader);
                    if(headRequest) {
                        return channel;
                    }
                    // fixed-length response
                    return new FixedLengthStreamSinkConduit(channel, contentLength, true, !exchange.isPersistent(), finishListener);
                } catch (NumberFormatException e) {
                    //we just fix it for them
                    responseHeaders.remove(Headers.CONTENT_LENGTH);
                }
            }
View Full Code Here

Examples of io.undertow.conduits.FixedLengthStreamSinkConduit

        boolean hasContent = true;

        if (fixedLengthString != null) {
            try {
                long length = Long.parseLong(fixedLengthString);
                conduit = new FixedLengthStreamSinkConduit(conduit, length, false, false, requestFinishListener);
                hasContent = length != 0;
            } catch (NumberFormatException e) {
                handleError(new IOException(e));
                return;
            }
        } else if (transferEncodingString != null) {
            if (!transferEncodingString.toLowerCase().contains(Headers.CHUNKED.toString())) {
                handleError(UndertowClientMessages.MESSAGES.unknownTransferEncoding(transferEncodingString));
                return;
            }
            conduit = new ChunkedStreamSinkConduit(conduit, false, false, requestFinishListener, httpClientExchange);
        } else {
            conduit = new FixedLengthStreamSinkConduit(conduit, 0, false, false, requestFinishListener);
            hasContent = false;
        }
        sinkChannel.setConduit(conduit);

        httpClientExchange.getReadyCallback().completed(httpClientExchange);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.