On Tue, Dec 20, 2005 at 03:14:39PM +0100, Roland Weber wrote: > Hello Harm, > > FTP and HTTP are completely different protocols. > You can not use HttpClient to access an FTP server. > > You may be able to tunnel FTP via an HTTP proxy, > but HttpClient will only help you with the tunnelling. > You still have to implement FTP yourself, including > the authentication against the FTP server. > > cheers, > Roland >
Roland, Actually some web proxies are capable of executing FTP requests on the client's behalf. So, this is a legitimate usage of HttpClient Harm, Please send a wire/context log of the HTTP session that exhibits the problem Oleg > > > > "Laat, Harm de" <[EMAIL PROTECTED]> > 20.12.2005 13:51 > Please respond to > "HttpClient User Discussion" > > > To > "'[email protected]'" > <[email protected]> > cc > > Subject > ftp via http > > > > > > > Hi all, > > I'm trying to access a FTP server via a HTTP proxy server (in this case > Microsoft ISA server). > > I have to authenticate with my FTP server. So I tried to incorporate my > username and password in the ftp url: > > ftp://test:[EMAIL PROTECTED]/test > > However, no luck just yet... I have also tried to set the username and > password with the setCredentials method. Also without luck. > > Can somebody please help??? > > > > I have written the following code: > > > // imports // > > public class TestClient { > > public static void main(String[] args) { > new TestClient().testFtpViaHttp(); > } > > public void testFtpViaHttp() { > > HttpClient client = new HttpClient(); > > HostConfiguration hostConfig = client.getHostConfiguration(); > hostConfig.setProxy("proxy", 8080); > client.setHostConfiguration(hostConfig); > > Protocol protol = new Protocol("ftp", new > DefaultProtocolSocketFactory(), 21); > Protocol.registerProtocol("ftp", protol); > > Credentials proxyCreds = new NTCredentials("username", "pass","", > "DOMAIN" ); > client.getState().setProxyCredentials(AuthScope.ANY, proxyCreds); > > GetMethod gmethod = new GetMethod("ftp://xxx.xxx.xxx.xxx/test/"); > > gmethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, > new DefaultHttpMethodRetryHandler(3, false)); > > try { > // Execute the method. > int statusCode = client.executeMethod(gmethod); > > if (statusCode != HttpStatus.SC_OK) { > System.err.println("Method failed: " + > gmethod.getStatusLine()); > } > > // Read the response body. > byte[] responseBody = gmethod.getResponseBody(); > > // Deal with the response. > // Use caution: ensure correct character encoding and is not > binary data > System.out.println(new String(responseBody)); > > } catch (HttpException e) { > System.err.println("Fatal protocol violation: " + > e.getMessage()); > e.printStackTrace(); > } catch (IOException e) { > System.err.println("Fatal transport error: " + > e.getMessage()); > e.printStackTrace(); > } finally { > // Release the connection. > gmethod.releaseConnection(); > } > > } > > } > > > Regards, > > Harm de Laat > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
