Http Client

N

nightmare

Gast
Hallo,

schreibe gerade ein Programm, welches sich automatisch in einem Forum anmelden soll. Erhalte ledigllich die Fehlermeldung:
org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded
INFO: Redirect requested but followRedirects is disabled


Java:
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

public class Test {

	static final String loginSite = "...";


	public static void main(String[] args) throws Exception {
		// Client erstellen

		// Post-Methode zum Einloggen erstellen
		HttpClient client = new HttpClient();
		PostMethod postMethod1 = new PostMethod(loginSite);
		postMethod1.getParams().setCookiePolicy(
				CookiePolicy.BROWSER_COMPATIBILITY);
		postMethod1.addParameter("username", "..");
		postMethod1.addParameter("password", "..");
		postMethod1.addParameter("target", "/index.php");

		postMethod1.setFollowRedirects(false);
		client.executeMethod(postMethod1);
		String vOutputPost = postMethod1.getResponseBodyAsString();
 
G

Gast2

Gast
Ist doch eigentlich ganz klar: Du sollst redirected werden, aber dein Client verweigert das ;)

Code:
org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded
und
Java:
postMethod1.setFollowRedirects(false);
passt nicht zusammen denke ich mal
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
J HTTP [Java 9] Neuer HTTP Client - Tutorial Netzwerkprogrammierung 3
F HTTP HTTP Rest Client mit TLS1.2 und selbst signiertem Zertifikat Netzwerkprogrammierung 2
P HTTP Server / Client Netzwerkprogrammierung 1
D Server Client Verbindung - Unexpected End of File - Invalid HTTP Response Netzwerkprogrammierung 4
R HTTP Apache HTTP Client: Request mit angehängter Datei Netzwerkprogrammierung 2
W Asynchroner HTTP Client / non-blocking I/O Netzwerkprogrammierung 2
C HTTP Studienarbeit Kommunikation via HTTP mit POST zwischen Server und Client Netzwerkprogrammierung 7
A org.apache.commons http client in Netbeans einbinden Netzwerkprogrammierung 3
G Http Client mit Redirect Enabled Netzwerkprogrammierung 2
I Apache http-client: Problem beim Proxyaufruf Netzwerkprogrammierung 2
G HTTP Client :: Komme nicht über den Proxy Netzwerkprogrammierung 7
G unvollständige Daten: Http Client-Server-Kommunikation Netzwerkprogrammierung 2
F http Post auf einen Grafana Server Netzwerkprogrammierung 3
H Datei mit Anhang via http "hochladen" Netzwerkprogrammierung 16
S HTTP Post?!? - Java Server Netzwerkprogrammierung 7
R Anfängerbeispiel: Suche Java-Anwendung die http-Anfragen in Tomcat liest Netzwerkprogrammierung 8
O HTTP Wer hilft mit meinem UTF-8 http Request ? Netzwerkprogrammierung 1
G localhost im Backend https vs. http Netzwerkprogrammierung 9
J Simple HTTP Framework (basierend auf expressjs) Netzwerkprogrammierung 1
M HTTP Http requests aufzeichnen Netzwerkprogrammierung 2
J HTTP Befehl via HTTP senden ohne Browser öffnen Netzwerkprogrammierung 3
M http request and response Netzwerkprogrammierung 0
M Verbindungszeit berechnen (TCP, HTTP/1.0, HTTP/1.1) Netzwerkprogrammierung 2
P HTTP Bild von einem Server per http kopieren Netzwerkprogrammierung 1
U HTTP XML vom Server abholen oder http Abfragen, Entscheidung treffen Netzwerkprogrammierung 0
S HTTP-Requeste von Browser mit Java sniffen? Netzwerkprogrammierung 9
E HTTP java.lang.IllegalArgumentException: protocol = http host = null Netzwerkprogrammierung 1
M Server mit HTTP Netzwerkprogrammierung 9
H Sockets oder HTTP- Methoden? Netzwerkprogrammierung 3
B Socket HTTP-Request führt zu Endlosschleife Netzwerkprogrammierung 5
D HTTP nochne frage zu http requests Netzwerkprogrammierung 6
D HTTP Bräuchte hilfe mit Http Requests Netzwerkprogrammierung 6
K HTTP Eigener Http Response für Datei-Download Netzwerkprogrammierung 4
F HTTP HTTP-Download: Dateien in einem Verzeichnis ermitteln Netzwerkprogrammierung 8
T HTTP Einen HTTP Server erstellen Netzwerkprogrammierung 20
N Problem über http eine Datei zu senden Netzwerkprogrammierung 4
Dit_ HTTP Einfache HTTP-Anfrage Netzwerkprogrammierung 6
nrg FileUpload HTTP POST Netzwerkprogrammierung 5
T Socket Java HTTP-Proxy Netzwerkprogrammierung 3
A HTTP Zugriff auf http-Server - Error 400 Netzwerkprogrammierung 11
B HTTP JSESSIONID in Http(s)URLConnection loswerden! Netzwerkprogrammierung 13
E Socket HTTP-Server Netzwerkprogrammierung 6
C HTTP POST Connect Netzwerkprogrammierung 9
D HTTP Java HTTP Kommunikation Netzwerkprogrammierung 9
O Http request Netzwerkprogrammierung 7
Tobse HTTP ServerSocket HTTP Netzwerkprogrammierung 4
I HTTP Datei Uploaden mit http und Sprache anpassen Netzwerkprogrammierung 7
I Socket HTTP Nachrichten über Sockets verschicken Netzwerkprogrammierung 2
R HTTP Problem bei Authentifizierung über (Http)UrlConnection Netzwerkprogrammierung 2
L Body eines http Request auslesen Netzwerkprogrammierung 2
T HTTP Encoding von Http-Streams Netzwerkprogrammierung 2
K Ende eines HTTP Response/Request Netzwerkprogrammierung 6
D http request Netzwerkprogrammierung 11
Kr0e Simpler HTTP Stream server Test Netzwerkprogrammierung 3
K HTTP-Anfrage an einen Server wird nicht beantwortet Netzwerkprogrammierung 3
J org.apache.http.auth.NTCredentials Netzwerkprogrammierung 2
W Problem mit HTTP-Dateiübertragung Netzwerkprogrammierung 6
M Http POST liefert kryptischen Content Netzwerkprogrammierung 4
G Sockets und HTTP: Ende des Datenempfangs erkennen Netzwerkprogrammierung 3
B Wie HTTP GET/POST Anfrage versenden? Netzwerkprogrammierung 7
R HTTP Server Memory Leak? Netzwerkprogrammierung 6
G HTTP-Request InputStream-Problem Netzwerkprogrammierung 5
K optimale HTTP Downloads Netzwerkprogrammierung 15
G auf http-request antworten. Netzwerkprogrammierung 3
I http sniffer gesucht Netzwerkprogrammierung 10
G Socket + HTTP Header Netzwerkprogrammierung 2
R HTTP ServerThread Netzwerkprogrammierung 4
J HTTP GET? Netzwerkprogrammierung 6
C FTP vs HTTP Netzwerkprogrammierung 10
M HTTP-Response extrem fragmentiert Netzwerkprogrammierung 4
W HTTP-Upload Netzwerkprogrammierung 2
M HTTP response code: 401 ; ?aber im browser ist es abrufbar? Netzwerkprogrammierung 5
L Java HTTP Request Netzwerkprogrammierung 3
O Axis2 erstellt HTTP/1.1 anstatt HTTP/1.0 Netzwerkprogrammierung 3
B Fehler 401 bei http GET Netzwerkprogrammierung 2
S HTTP Request erstellen Netzwerkprogrammierung 2
E upload progress bei einem http file post Netzwerkprogrammierung 5
B lange Strings in http-Request? Netzwerkprogrammierung 3
K http-download Netzwerkprogrammierung 12
M erst POST dann Http-Request über URLConnection Netzwerkprogrammierung 3
m@nu Ende von Stream bei HTTP-Request Netzwerkprogrammierung 3
M RMI over HTTP Netzwerkprogrammierung 5
M HTTP Requests verarbeiten und Response senden mit Java Netzwerkprogrammierung 14
G HTTP Response mit Transfer-Encoding:chunked einlesen Netzwerkprogrammierung 4
D HTTP Request erstellen (Form Name übergeben!) Netzwerkprogrammierung 3
J Java Programm für Upload von Dateien per HTTP Netzwerkprogrammierung 7
L http kommunikation mit und ohne multipart Netzwerkprogrammierung 4
L file upload / download über http Netzwerkprogrammierung 5
P Easy Http Request Netzwerkprogrammierung 9
B non US-ASCII Dateinamen über HTTP? Netzwerkprogrammierung 2
N Dateigröße einer Datei auf einem HTTP-/Web-Server. Netzwerkprogrammierung 9
P File von http-Server kopieren Netzwerkprogrammierung 5
G http 1.1 socket? Netzwerkprogrammierung 3
J HTTP-POST-Request mit Anhang über Socket Netzwerkprogrammierung 2
S http Server selber schreiben Netzwerkprogrammierung 5
S Suche API für einfachen HTTP-Zugriff. Netzwerkprogrammierung 17
Z HTTP Request Netzwerkprogrammierung 3
A http request per socket an apache server Netzwerkprogrammierung 5
M Ein HTTP-request aus Java heraus senden Netzwerkprogrammierung 3
N Download HTTP .php-Seite mit Anmeldung Netzwerkprogrammierung 5

Ähnliche Java Themen

Neue Themen


Oben