Re: URL mit Passwort
- From: Ralf Ullrich <news@xxxxxxxx>
- Date: Tue, 09 Aug 2005 21:54:17 +0200
Michael Konietzka wrote:
Ingo R. Homann wrote:
Hi,
Michael Konietzka wrote:
Ich möchte eine URL-Verbindung öffnen, um eine Text-Datei auszulesen, die per http zugänglich ist, aber eine Authentifizierung erfordert.
Die URL-Klasse scheint das so direkt nicht zu unterstützen:
URL url = new URL("http://user:password@xxxxxxxxxx"); BufferedReader in = new BufferedReader(new InputStreamReader( url.openStream()));
Der Code wirft einen 401er.
Zurecht, denn AFAIK ist die Kurzform "user:password@xxxxxxxxxx" laut irgendwelchen HTTP-RFCs auch nicht erlaubt.
In irgendwelchen RFCs hab' ich aber genau das gelesen...
Genauer lesen. ;-) Aus http://www.faqs.org/rfcs/rfc1738.html
"3.3. HTTP
The HTTP URL scheme is used to designate Internet resources accessible using HTTP (HyperText Transfer Protocol).
The HTTP protocol is specified elsewhere. This specification only describes the syntax of HTTP URLs.
An HTTP URL takes the form:
http://<host>:<port>/<path>?<searchpart>
where <host> and <port> are as described in Section 3.1. If :<port> is omitted, the port defaults to 80. No user name or password is allowed. " Username und Passwort sind also nicht erlaubt.
Aus RFC1738 (Dank deinem Link gleich gefunden.):
3.1. Common Internet Scheme Syntax
While the syntax for the rest of the URL may vary depending on the particular scheme selected, URL schemes that involve the direct use of an IP-based protocol to a specified host on the Internet use a common syntax for the scheme-specific data:
//<user>:<password>@<host>:<port>/<url-path>
Some or all of the parts "<user>:<password>@", ":<password>", ":<port>", and "/<url-path>" may be excluded. The scheme specific data start with a double slash "//" to indicate that it complies with the common Internet scheme syntax. The different components obey the following rules:
user
An optional user name. Some schemes (e.g., ftp) allow the
specification of a user name. password
An optional password. If present, it follows the user
name separated from it by a colon.
Username und Password sind also erlaubt. ;-)
cu .
- Follow-Ups:
- Re: URL mit Passwort
- From: Stefan Matthias Aust
- Re: URL mit Passwort
- References:
- URL mit Passwort
- From: Ingo R. Homann
- Re: URL mit Passwort
- From: Michael Konietzka
- Re: URL mit Passwort
- From: Ingo R. Homann
- Re: URL mit Passwort
- From: Michael Konietzka
- URL mit Passwort
- Prev by Date: Re: werfen einer checked Exception ohne throws Deklaration
- Next by Date: Re: [Eclipse][FYI] draft 3.2 plan
- Previous by thread: Re: URL mit Passwort
- Next by thread: Re: URL mit Passwort
- Index(es):
Relevant Pages
|
Loading