T
tsxn26
I'm trying to code a simple http client that receives a requested
resource from an http server. Something that is puzzling me is that
the InputStream from the socket is coming up empty after requesting the
resource. Here is an similar example of my code:
Socket sock = new Socket(server, port);
OutputStream out = sock.getOutputStream();
InputStream in = sock.getInputStream();
/* Code to send http request to http server here */
System.out.println("The size of the input stream is: " +
in.available());
The output from the println statement is always 0. I'm positive that
the request has been received from the http server because I'm also
running a http server class that shows the file name of the GET
request. The server sends the resource by the following code:
FileInputStream fis = new FileInputStream(req);
byte[] data = new byte[fis.available()];
fis.read(data);
out.write(data);
Can anyone spot out why my clientside InputStream is always empty?
resource from an http server. Something that is puzzling me is that
the InputStream from the socket is coming up empty after requesting the
resource. Here is an similar example of my code:
Socket sock = new Socket(server, port);
OutputStream out = sock.getOutputStream();
InputStream in = sock.getInputStream();
/* Code to send http request to http server here */
System.out.println("The size of the input stream is: " +
in.available());
The output from the println statement is always 0. I'm positive that
the request has been received from the http server because I'm also
running a http server class that shows the file name of the GET
request. The server sends the resource by the following code:
FileInputStream fis = new FileInputStream(req);
byte[] data = new byte[fis.available()];
fis.read(data);
out.write(data);
Can anyone spot out why my clientside InputStream is always empty?