Redirected wikipedia request

Posted by Le_Coeur on Stack Overflow See other posts from Stack Overflow or by Le_Coeur
Published on 2010-05-20T15:40:25Z Indexed on 2010/05/20 16:20 UTC
Read the original article Hit count: 250

Hi people,

i need to write a program, that can redirect's http://localhost:8080 to en.wikipedia.org, it seems to be easy, but i have some problems(only with wikipedia with another sites works good). I make url to wikipedia:

URL url = new URL("http", "en.wikipedia.org", 80, "/wiki");

than URLConnection, extract headers, and when i want connection.getInputStream(), i received message 404 Not Found. So i have tried some hack for host header, because in this way host header is localhost:8080, therefor i have tried to change host header to wikipedia, and it works, but after request in browser http://localhost:8080 wikipedia opens, but url in browser changes to en.wikipedia.org, but i want proceed with localhost :)

© Stack Overflow or respective owner

Related posts about java

Related posts about http-header-fields