private static Response PostParameters(string parameter_string)
{
WebRequest conn;
try {
conn = WebRequest.Create (URL);
}
catch (SecurityException) {
throw;
}
conn.Method = "POST";
conn.ContentType = "application/x-www-form-urlencoded";
byte[] buf = Encoding.UTF8.GetBytes (parameter_string);
conn.ContentLength = buf.Length;
Stream stream = conn.GetRequestStream ();
try {
stream.Write (buf, 0, buf.Length);
}
catch (IOException) {
throw;
}
finally {
stream.Close ();
}
WebResponse response = null;
// FIXME ugh... we shouldn't need to trap any exceptions
// but apparently upcoming.org returns 404 Not found exception
// on e.g. "watchlist.remove", so we don't want to die on the response giving errors.
// There ain't much we can do about it for now though.
try {
response = conn.GetResponse ();
return (Response)response_serializer.Deserialize (response.GetResponseStream ());
}
catch {
return null;
}
finally {
if (response != null)
response.Close ();
}
}