I'm trying to write proxy server on localhost with port 8080 using just ServerSocket and Socket. I just want to see TEXT from website. I have created HTTP Request and i'm not sure if it's written good. The problem is with HTTP Response from a server, beacuse it's not returning anything. But first i want to know if request is good.
Then in Thread i'm just Reading request and sending it to a server:
BufferedReader fromClient = new BufferedReader(new InputStreamReader(socket.getInputStream());
HttpRequest req = new HttpRequest(fromClient);
Socket server = new Socket(req.getHost(), req.getPort());
DataOutputStream toServer = new DataOutputStream(server.getOutputStream());
toServer.writeBytes(req.toString());
Let's break this problem into several parts:
wget website_name_here
. This will tell you if there's a configuration problem in server itself. This will confirm if HTTP response coming from server is good enough.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.