Examples of ContentLengthInputStream


Examples of ch.iterate.openstack.swift.io.ContentLengthInputStream

     *
     * @return An input stream that will return the response body when read
     * @throws IOException If an error occurs reading the input stream
     */
    public ContentLengthInputStream getResponseBodyAsStream() throws IOException {
        return new ContentLengthInputStream(response.getEntity().getContent(), response.getEntity().getContentLength());
    }
View Full Code Here

Examples of com.ericsson.ssa.utils.ContentLengthInputStream

                InputStream is = connection.getInputStream();

                if (chunked) {
                    is = new ChunkedInputStream(is);
                } else {
                    is = new ContentLengthInputStream(is, contentLength);
                }

                byte[] buffer = new byte[8192];
                int length;
View Full Code Here

Examples of com.ericsson.ssa.utils.ContentLengthInputStream

                contentType.toLowerCase()
                               .startsWith("application/x-www-form-urlencoded") &&
                cRequest.getMethod().equalsIgnoreCase("POST")) {
            // Wrapping the already read POST data in a bounded InputStream.
            HttpFormData data = new HttpFormData(request);
            in = new ContentLengthInputStream(new ByteArrayInputStream(
                        data.getData()), data.getLength());
        } else {
            // Using the standard InputStream of the request.
            in = new ContentLengthInputStream(cRequest.getInputStream(),
                    contentLength);
        }

        return in;
    }
View Full Code Here

Examples of com.ramforth.webserver.http.parsers.ContentLengthInputStream

        socket = null;
        //}
    }

    private void handleClient() throws IOException, SocketTimeoutException {
        InputStream is = new ContentLengthInputStream(new BufferedInputStream(socket.getInputStream()), maximumRequestLengthInBytes);
        OutputStream os = new BufferedOutputStream(socket.getOutputStream());

        /*
         * we will only block in read for this many milliseconds before we fail with
         * java.io.InterruptedIOException, at which point we will abandon the
         * connection.
         */
        socket.setSoTimeout(1000000/* WebServer.timeout */);
        socket.setTcpNoDelay(true);
       
        clearBuffer();

        try {
            IHttpContext context = establishContext(is, socket.getInetAddress(), os);

            handleContext(context);
        }
        catch (ResourceNotFoundException rnfex) {
            IHttpResponse httpResponse = createHttpResponseForStatusCode(HttpStatusCode.STATUS_404_NOT_FOUND);

            IHttpResponseWriter responseWriter = new HttpResponseWriter(os);
            responseWriter.writeResponse(httpResponse);
        }
        catch (HttpException he) {
            IHttpResponse httpResponse = createHttpResponseForStatusCode(he.getStatusCode());

            IHttpResponseWriter responseWriter = new HttpResponseWriter(os);
            responseWriter.writeResponse(httpResponse);
        }
        catch (SocketTimeoutException ste) {
            IHttpResponse httpResponse = createHttpResponseForStatusCode(HttpStatusCode.STATUS_408_REQUEST_TIMEOUT);

            IHttpResponseWriter responseWriter = new HttpResponseWriter(os);
            responseWriter.writeResponse(httpResponse);
        }
        finally {
            if (!socket.isClosed()) {
                try {
                    os.flush();

                    is.close();
                    os.close();

                    socket.close();
                }
                catch (IOException ex) {
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                    in = new ChunkedInputStream(in);
                }
            } else if (contentLength != null) {
                long len = getContentLength();
                if (len >= 0) {
                    in = new ContentLengthInputStream(in, len);
                }
            }
            this.entity = in;
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                        in = new ChunkedInputStream(in);
                    }
                } else if (contentLength != null) {
                    long len = getContentLength();
                    if (len >= 0) {
                        in = new ContentLengthInputStream(in, len);
                    }
                }
                this.entity = in;
            }
        }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

            outstream = new ChunkedOutputStream(outstream);
        }
        if (contentLength >= 0) {
            // don't need a watcher here - we're reading from something local,
            // not server-side.
            instream = new ContentLengthInputStream(instream, contentLength);
        }

        byte[] tmp = new byte[4096];
        int total = 0;
        int i = 0;
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                        in = new ChunkedInputStream(in);
                    }
                } else if (contentLength != null) {
                    long len = getContentLength();
                    if (len >= 0) {
                        in = new ContentLengthInputStream(in, len);
                    }
                }
                this.entity = in;
            }
        }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

                    in = new ChunkedInputStream(in);
                }
            } else if (contentLength != null) {
                long len = getContentLength();
                if (len >= 0) {
                    in = new ContentLengthInputStream(in, len);
                }
            }
            this.entity = in;
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.ContentLengthInputStream

            outstream = new ChunkedOutputStream(outstream);
        }
        if (this.requestContentLength >= 0) {
            // don't need a watcher here - we're reading from something local,
            // not server-side.
            instream = new ContentLengthInputStream(instream, this.requestContentLength);
        }

        byte[] tmp = new byte[4096];
        int total = 0;
        int i = 0;
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.