Hello!
I have a J# socket client that does an HTTP Post. Code pasted below. This
client works fine on my XP and Win 2003 boxes, but on my Win 2000 Server box,
the socket just hangs when it tries to read. No exception nothing just hangs.
Any suggestion?
public static String httpPost(String url, String payload, String
ContentType)throws Exception, System.Exception
{
WebResponse result = null;
StreamReader sr = null;
try
{
WebRequest req = WebRequest.Create(url);
req.set_Method("POST");
//req.set_ContentType("application/x-www-form-urlencoded");
req.set_ContentType(ContentType);
ubyte[] SomeBytes = null;
if (payload != null)
{
//SomeBytes = HttpUtility.UrlEncodeToBytes(payload);
SomeBytes = Encoding.get_UTF8().GetBytes(payload);
req.set_ContentLength(SomeBytes.length);
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.length);
newStream.Close();
}
else
{
req.set_ContentLength(0);
}
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
sr = new StreamReader(ReceiveStream, encode);
System.Text.StringBuilder strb = new StringBuilder();
String str;
while ((str = sr.ReadLine()) != null)
{
strb.Append(str).Append( "\r\n");
}
return System.Web.HttpUtility.UrlDecode(strb.ToString(), encode);
}
catch(Exception e)
{
throw e;
}
catch (System.Exception se)
{
throw se;
}
finally
{
if(sr != null)
sr.Close();
if (result != null)
result.Close();
}
}//getPage