com.sun.xml.internal.ws.client.ClientTransportException Java Examples

The following examples show how to use com.sun.xml.internal.ws.client.ClientTransportException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientTransport.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
OutputStream getOutput() {
    try {
        createHttpConnection();
        // for "GET" request no need to get outputStream
        if (requiresOutputStream()) {
            outputStream = httpConnection.getOutputStream();
            if (chunkSize != null) {
                outputStream = new WSChunkedOuputStream(outputStream, chunkSize);
            }
            List<String> contentEncoding = reqHeaders.get("Content-Encoding");
            // TODO need to find out correct encoding based on q value - RFC 2616
            if (contentEncoding != null && contentEncoding.get(0).contains("gzip")) {
                outputStream = new GZIPOutputStream(outputStream);
            }
        }
        httpConnection.connect();
    } catch (Exception ex) {
        throw new ClientTransportException(
            ClientMessages.localizableHTTP_CLIENT_FAILED(ex),ex);
    }

    return outputStream;
}
 
Example #2
Source File: HttpClientTransport.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
OutputStream getOutput() {
    try {
        createHttpConnection();
        // for "GET" request no need to get outputStream
        if (requiresOutputStream()) {
            outputStream = httpConnection.getOutputStream();
            if (chunkSize != null) {
                outputStream = new WSChunkedOuputStream(outputStream, chunkSize);
            }
            List<String> contentEncoding = reqHeaders.get("Content-Encoding");
            // TODO need to find out correct encoding based on q value - RFC 2616
            if (contentEncoding != null && contentEncoding.get(0).contains("gzip")) {
                outputStream = new GZIPOutputStream(outputStream);
            }
        }
        httpConnection.connect();
    } catch (Exception ex) {
        throw new ClientTransportException(
            ClientMessages.localizableHTTP_CLIENT_FAILED(ex),ex);
    }

    return outputStream;
}
 
Example #3
Source File: HttpClientTransport.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
OutputStream getOutput() {
    try {
        createHttpConnection();
        // for "GET" request no need to get outputStream
        if (requiresOutputStream()) {
            outputStream = httpConnection.getOutputStream();
            if (chunkSize != null) {
                outputStream = new WSChunkedOuputStream(outputStream, chunkSize);
            }
            List<String> contentEncoding = reqHeaders.get("Content-Encoding");
            // TODO need to find out correct encoding based on q value - RFC 2616
            if (contentEncoding != null && contentEncoding.get(0).contains("gzip")) {
                outputStream = new GZIPOutputStream(outputStream);
            }
        }
        httpConnection.connect();
    } catch (Exception ex) {
        throw new ClientTransportException(
            ClientMessages.localizableHTTP_CLIENT_FAILED(ex),ex);
    }

    return outputStream;
}
 
Example #4
Source File: HttpTransportPipe.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #5
Source File: HttpTransportPipe.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #6
Source File: HttpTransportPipe.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #7
Source File: HttpTransportPipe.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #8
Source File: HttpTransportPipe.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #9
Source File: HttpTransportPipe.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #10
Source File: HttpTransportPipe.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #11
Source File: HttpTransportPipe.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #12
Source File: HttpTransportPipe.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #13
Source File: HttpTransportPipe.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #14
Source File: HttpTransportPipe.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #15
Source File: HttpTransportPipe.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #16
Source File: HttpTransportPipe.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #17
Source File: HttpTransportPipe.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}
 
Example #18
Source File: HttpTransportPipe.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
    con.readResponseCodeAndMessage();   // throws IOE
    recordCookies(request, con);

    InputStream responseStream = con.getInput();
    if (dump || LOGGER.isLoggable(Level.FINER)) {
        ByteArrayBuffer buf = new ByteArrayBuffer();
        if (responseStream != null) {
            buf.write(responseStream);
            responseStream.close();
        }
        dump(buf,"HTTP response - "+request.endpointAddress+" - "+con.statusCode, con.getHeaders());
        responseStream = buf.newInputStream();
    }

    // Check if stream contains any data
    int cl = con.contentLength;
    InputStream tempIn = null;
    if (cl == -1) {                     // No Content-Length header
        tempIn = StreamUtils.hasSomeData(responseStream);
        if (tempIn != null) {
            responseStream = tempIn;
        }
    }
    if (cl == 0 || (cl == -1 && tempIn == null)) {
        if(responseStream != null) {
            responseStream.close();         // No data, so close the stream
            responseStream = null;
        }

    }

    // Allows only certain http status codes for a binding. For all
    // other status codes, throws exception
    checkStatusCode(responseStream, con); // throws ClientTransportException

    Packet reply = request.createClientResponse(null);
    reply.wasTransportSecure = con.isSecure();
    if (responseStream != null) {
        String contentType = con.getContentType();
        if (contentType != null && contentType.contains("text/html") && binding instanceof SOAPBinding) {
            throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(con.statusCode, con.statusMessage));
        }
        codec.decode(responseStream, contentType, reply);
    }
    return reply;
}