Applet: SocketException Unbekannten proxy-Typ : HTTP

Habe ich keine Probleme, läuft mein applet in Eclipse, aber wenn ich mich Anmelde und führen Sie es im browser passiert

10-abr-2013 19:54:37 org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Unknown proxy type : HTTP
10-abr-2013 19:54:37 org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: Retrying connect
…
java.net.SocketException: Unknown proxy type : HTTP
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source) 

Hier im Versuch zum hochladen einiger Dateien mit org.apache.http.client.HttpClient

public static String executeMultiPartRequest(String urlString, File file,
        String fileName, String fileDescription) {

    System.out.println("SET URI " + urlString);
    HttpPost postRequest = new HttpPost(urlString);
    try {

        MultipartEntity multiPartEntity = new MultipartEntity();

        //The usual form parameters can be added this way
        multiPartEntity.addPart("fileDescription", new StringBody(
                fileDescription != null ? fileDescription : ""));
        multiPartEntity.addPart("fileName", new StringBody(
                fileName != null ? fileName : file.getName()));

        /*
         * Need to construct a FileBody with the file that needs to be
         * attached and specify the mime type of the file. Add the fileBody
         * to the request as an another part. This part will be considered
         * as file part and the rest of them as usual form-data parts
         */
        FileBody fileBody = new FileBody(file, "application/octect-stream");
        multiPartEntity.addPart("attachment", fileBody);

        //multiPartEntity.addPart("path", Charset.forName("UTF-8"));

        postRequest.setEntity(multiPartEntity);
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    }

    return executeRequest(postRequest);
}

private static String executeRequest(HttpRequestBase requestBase) {
    String responseString = "";

    InputStream responseStream = null;
    HttpClient client = new DefaultHttpClient();
    try {
        System.out.println("LISTO PARA ENVIAR A" + requestBase.getURI());
        HttpResponse response = client.execute(requestBase);
        if (response != null) {
            HttpEntity responseEntity = response.getEntity();

            if (responseEntity != null) {
                responseStream = responseEntity.getContent();
                if (responseStream != null) {
                    BufferedReader br = new BufferedReader(
                            new InputStreamReader(responseStream));
                    String responseLine = br.readLine();
                    String tempResponseString = "";
                    while (responseLine != null) {
                        tempResponseString = tempResponseString
                                + responseLine
                                + System.getProperty("line.separator");
                        responseLine = br.readLine();
                    }
                    br.close();
                    if (tempResponseString.length() > 0) {
                        responseString = tempResponseString;
                    }
                }
            }
        }
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (responseStream != null) {
            try {
                responseStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    client.getConnectionManager().shutdown();

    return responseString;
}

Was Ihr falsch?

Applet ist signiert und kompiliert mit java 1.6, httpclient-4.1.3.jar

Schreibe einen Kommentar