this is for holding javascript data
Thomas added Beispiel_fr_das_Folgen_einer__.tex
almost 8 years ago
Commit id: 8526e4e8b4b96657dcbd02895b4918e61d6455d7
deletions | additions
diff --git a/Beispiel_fr_das_Folgen_einer__.tex b/Beispiel_fr_das_Folgen_einer__.tex
new file mode 100644
index 0000000..bd26767
--- /dev/null
+++ b/Beispiel_fr_das_Folgen_einer__.tex
...
Beispiel fr das Folgen einer Weiterleitung:
\begin{lstlisting}
URL url = new URL("http://php.net/existiertnicht");
HttpURLConnection con;
while (true) {
con = (HttpURLConnection) url.openConnection();
con.setInstanceFollowRedirects(false);
switch (con.getResponseCode()) {
case HttpURLConnection.HTTP_MOVED_PERM:
case HttpURLConnection.HTTP_MOVED_TEMP:
String next = con.getHeaderField("Location");
url = new URL(url, next);
continue;
}
break;
}
// redirects to
// http://php.net/manual-lookup.php?pattern=existiertnicht&lang=en&scope=404quickref
\end{lstlisting}
Wenn die URL in der Variable \texttt{next} mit \texttt{https://} anfngt, muss die
Klasse \texttt{HttpsURLConnection} verwendet werden.