Problems Making a "POST" to a Socket
I am having problems making a Post from an HTML page to a Socket. It appears that when I attempt to parse the input, the blank line between the header and data (line 6 of the HTML post example below) causes the "inputStream" never to return.
Code :
....
outputStream = new BufferedOutputStream(clientSocket.getOutputStream());
InputStream inputStream = new BufferedInputStream(clientSocket.getInputStream());
StringBuilder sbRequest = new StringBuilder();
while (true) {
int byRead = inputStream.read();
if (byRead == -1) break;
sbRequest.append((char)byRead);
}
String sRequest = new String(sbRequest);
...
An example of a HTML post.
Code :
POST /login.jsp HTTP/1.1
Host: www.mysite.com
User-Agent: Mozilla/4.0
Content-Length: 27
Content-Type: application/x-www-form-urlencoded
userid=joe&password=guessme
Any help will be gratefully receive.
Kind Regards,
Harold Clements