Zum Inhalt springen

madmufflon

Mitglieder
  • Gesamte Inhalte

    1
  • Benutzer seit

  • Letzter Besuch

  1. Hey, ich habe folgendes Problem: ich mache eine URLConnection auf und will nun daten über nen proxy zum server schicken, aber leider klappt das nicht so wie es soll. Hier erstmal mein Code: //mein code, im programm in irgendeiner funktion urlconnection = getUrl(); this.setHeaderAndFooter(); DataOutputStream out = new DataOutputStream(urlconnection.getOutputStream()); out.writeBytes("string=hallowelt"); out.close(); BufferedReader URLinput = new BufferedReader( new InputStreamReader(urlconnection.getInputStream())); URLinput.close(); System.exit(0); private void setHeaderAndFooter() throws IOException{ urlconnection.addRequestProperty("Host", url.getHost()); urlconnection.addRequestProperty("User-Agent","Mozilla/5.0 (Java/UploadVertretungsplan;)"); urlconnection.addRequestProperty("Accept","text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"); urlconnection.addRequestProperty("Accept-Language","en-us,en;q=0.5"); urlconnection.addRequestProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); urlconnection.addRequestProperty("Connection", "close"); urlconnection.addRequestProperty("Content-Type","multipart/form-data; boundary=" + boundary); } private URLConnection getUrl() throws IOException, UnknownHostException{ //Das ganze läuft immer noch über einen proxy URLConnection urlc; Proxy pr; int port = main.getProxyPort(); if(port < 1) { port = 80; } InetAddress ip = Inet4Address.getByName(main.getProxy()); InetSocketAddress sa = new InetSocketAddress(ip,port); pr = new Proxy(Proxy.Type.HTTP, sa); urlc = url.openConnection(pr); urlc.setDoOutput(true); return urlc; } (Das Programm macht so nich so richtig sinn, is zum testen) Sieht ja soweit aus wie in den verschiedenen Tutorials, die ich gefunden hab, funktioniert nur leider nicht. Beim Server kommt nämlich folgendes an: POST /test/javaUpload.php HTTP/1.0 Host:localhost User-Agent:Mozilla/5.0 (Java/UploadVertretungsplan;) Accept:text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language:en-us,en;q=0.5 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7 Content-Type:multipart/form-data; boundary=wyqyygmppuujegjkifhzwlgrcqeugwwepzwyrhqz Content-Length:16 Via:1.1 martin%3a3128 (squid/2.7.STABLE3) X-Forwarded-For:127.0.0.1 Cache-Control:max-age=259200 Connection:keep-alive Kann mir jemand sagen, warum das nicht richtig ankommt? bin für jede hilfe dankbar grüße martin

Fachinformatiker.de, 2024 by SE Internet Services

fidelogo_small.png

Schicke uns eine Nachricht!

Fachinformatiker.de ist die größte IT-Community
rund um Ausbildung, Job, Weiterbildung für IT-Fachkräfte.

Fachinformatiker.de App

Download on the App Store
Get it on Google Play

Kontakt

Hier werben?
Oder sende eine E-Mail an

Social media u. feeds

Jobboard für Fachinformatiker und IT-Fachkräfte

×
×
  • Neu erstellen...