Weitere aktuelle Java-Titel finden Sie bei dpunkt.
 Inhaltsverzeichnis   Vorhergehendes Paket   Seite Zurück   Seite Vor   Nächstes Paket   Paketübersicht   Index

Klasse java.net.HttpURLConnection1.1

java.lang.Object
   |
   +--java.net.URLConnection
         |
         +--java.net.HttpURLConnection

Deklaration

public abstract class HttpURLConnection
extends java.net.URLConnection

Beschreibung

Die Klasse HttpURLConnection ist eine Spezialisierung der URLConnection, die besonders auf HTTP-Verbindungen abgestimmt ist. Beispielsweise ist es möglich, die Request-Methode einzustellen oder anzugeben, ob HTTP-Redirects verfolgt werden sollen.


 
Datenelemente
protected Stringmethod
protected intresponseCode
protected StringresponseMessage
public static final intHTTP_OK
public static final intHTTP_CREATED
public static final intHTTP_ACCEPTED
public static final intHTTP_NOT_AUTHORITATIVE
public static final intHTTP_NO_CONTENT
public static final intHTTP_RESET
public static final intHTTP_PARTIAL
public static final intHTTP_MULT_CHOICE
public static final intHTTP_MOVED_PERM
public static final intHTTP_MOVED_TEMP
public static final intHTTP_SEE_OTHER
public static final intHTTP_NOT_MODIFIED
public static final intHTTP_USE_PROXY
public static final intHTTP_BAD_REQUEST
public static final intHTTP_UNAUTHORIZED
public static final intHTTP_PAYMENT_REQUIRED
public static final intHTTP_FORBIDDEN
public static final intHTTP_NOT_FOUND
public static final intHTTP_BAD_METHOD
public static final intHTTP_NOT_ACCEPTABLE
public static final intHTTP_PROXY_AUTH
public static final intHTTP_CLIENT_TIMEOUT
public static final intHTTP_CONFLICT
public static final intHTTP_GONE
public static final intHTTP_LENGTH_REQUIRED
public static final intHTTP_PRECON_FAILED
public static final intHTTP_ENTITY_TOO_LARGE
public static final intHTTP_REQ_TOO_LONG
public static final intHTTP_UNSUPPORTED_TYPE
public static final intHTTP_SERVER_ERROR
public static final intHTTP_INTERNAL_ERROR
public static final intHTTP_BAD_GATEWAY
public static final intHTTP_UNAVAILABLE
public static final intHTTP_GATEWAY_TIMEOUT
public static final intHTTP_VERSION
 
Konstruktoren
protectedHttpURLConnection(URL u)
 
Methoden
public abstract voiddisconnect()
public InputStreamgetErrorStream()     [1.2]
public static booleangetFollowRedirects()
public longgetHeaderFieldDate(String name, long default)     [1.3]
public booleangetInstanceFollowRedirects()     [1.3]
public PermissionCollectiongetPermission()     [1.2]
public StringgetRequestMethod()
public intgetResponseCode()
public StringgetResponseMessage()
public static voidsetFollowRedirects(boolean set)
public voidsetInstanceFollowRedirects(boolean followRedirects)     [1.3]
public voidsetRequestMethod(String method)
public abstract booleanusingProxy()


 

Datenelemente im Detail

protected String method
Die HTTP-Methode. Voreinstellung ist GET.
protected int responseCode
Enthält den Response-Code der Antwort.
protected String responseMessage
Enthält die Nachricht der Antwort.
public static final int HTTP_OK = 200
Konstante für getResponseCode().
public static final int HTTP_CREATED = 201
Konstante für getResponseCode().
public static final int HTTP_ACCEPTED = 202
Konstante für getResponseCode().
public static final int HTTP_NOT_AUTHORITATIVE = 203
Konstante für getResponseCode().
public static final int HTTP_NO_CONTENT = 204
Konstante für getResponseCode().
public static final int HTTP_RESET = 205
Konstante für getResponseCode().
public static final int HTTP_PARTIAL = 206
Konstante für getResponseCode().
public static final int HTTP_MULT_CHOICE = 300
Konstante für getResponseCode().
public static final int HTTP_MOVED_PERM = 301
Konstante für getResponseCode().
public static final int HTTP_MOVED_TEMP = 302
Konstante für getResponseCode().
public static final int HTTP_SEE_OTHER = 303
Konstante für getResponseCode().
public static final int HTTP_NOT_MODIFIED = 304
Konstante für getResponseCode().
public static final int HTTP_USE_PROXY = 305
Konstante für getResponseCode().
public static final int HTTP_BAD_REQUEST = 400
Konstante für getResponseCode().
public static final int HTTP_UNAUTHORIZED = 401
Konstante für getResponseCode().
public static final int HTTP_PAYMENT_REQUIRED = 402
Konstante für getResponseCode().
public static final int HTTP_FORBIDDEN = 403
Konstante für getResponseCode().
public static final int HTTP_NOT_FOUND = 404
Konstante für getResponseCode().
public static final int HTTP_BAD_METHOD = 405
Konstante für getResponseCode().
public static final int HTTP_NOT_ACCEPTABLE = 406
Konstante für getResponseCode().
public static final int HTTP_PROXY_AUTH = 407
Konstante für getResponseCode().
public static final int HTTP_CLIENT_TIMEOUT = 408
Konstante für getResponseCode().
public static final int HTTP_CONFLICT = 409
Konstante für getResponseCode().
public static final int HTTP_GONE = 410
Konstante für getResponseCode().
public static final int HTTP_LENGTH_REQUIRED = 411
Konstante für getResponseCode().
public static final int HTTP_PRECON_FAILED = 412
Konstante für getResponseCode().
public static final int HTTP_ENTITY_TOO_LARGE = 413
Konstante für getResponseCode().
public static final int HTTP_REQ_TOO_LONG = 414
Konstante für getResponseCode().
public static final int HTTP_UNSUPPORTED_TYPE = 415
Konstante für getResponseCode().
public static final int HTTP_SERVER_ERROR = 500
Konstante für getResponseCode().
public static final int HTTP_INTERNAL_ERROR = 501
Konstante für getResponseCode().
public static final int HTTP_BAD_GATEWAY = 502
Konstante für getResponseCode().
public static final int HTTP_UNAVAILABLE = 503
Konstante für getResponseCode().
public static final int HTTP_GATEWAY_TIMEOUT = 504
Konstante für getResponseCode().
public static final int HTTP_VERSION = 505
Konstante für getResponseCode().

 

Konstruktoren im Detail

protected HttpURLConnection(URL u)
Erzeugt ein neues HttpURLConnection-Objekt für die URL u.

 

Methoden im Detail

public abstract void disconnect()
Beendet die Verbindung zum Server.
public InputStream getErrorStream()     [1.2]
Liefert einen Stream, mit dem Daten gelesen werden können, die der Server im Falle eines Fehlers schickt, z. B., eine Hilfe-Seite, wenn eine URL nicht gefunden werden konnte.
public static boolean getFollowRedirects()
Liefert true, falls HTTP-Redirects verfolgt werden, sonst false.
public long getHeaderFieldDate(String name, long default)     [1.3]
Liefert den Wert des durch name bezeichneten Header-Felds als Datum zurück. Der Rückgabewert ist dabei die Anzahl an Millisekunden seit dem 01.01.1970, 00:00h. Mit default kann ein Standardwert gesetzt werden, der zurückgegeben wird, falls der Header-Eintrag nicht existiert.
public boolean getInstanceFollowRedirects()     [1.3]
Liefert den Wert des entsprechenden Header-Eintrags zurück.
public PermissionCollection getPermission()     [1.2]
Liefert die Berechtigung zurück, die für die Verbindung benötigt wird.
public String getRequestMethod()
Liefert die Request-Methode im Klartext.
public int getResponseCode()
Liefert den Response-Code der Antwort.
Exception: IOException
public String getResponseMessage()
Liefert die Nachricht der Antwort.
Exception: IOException
public static void setFollowRedirects(boolean set)
Stellt ein, ob HTTP-Redirects verfolgt werden sollen oder nicht.
public void setInstanceFollowRedirects(boolean followRedirects)     [1.3]
Stellt ein, ob HTTP-Redirects bei diesem Exemplar automatisch verfolgt werden sollen.
public void setRequestMethod(String method)
Setzt die Request-Methode auf method. Gültige Methoden sind:
Exception: ProtocolException
public abstract boolean usingProxy()
Liefert true, falls die Verbindung durch einen Proxy-Server geht, sonst false.


 Inhaltsverzeichnis   Vorhergehendes Paket   Seite Zurück   Seite Vor   Nächstes Paket   Paketübersicht   Index

Copyright © 2002 dpunkt.Verlag, Heidelberg. Alle Rechte vorbehalten.