~psgenfan/do-plugins/WolframAlpha

« back to all changes in this revision

Viewing changes to Pastebin/src/Pastebin.cs

  • Committer: Robert Dyer
  • Date: 2011-01-06 22:52:25 UTC
  • Revision ID: psybers@gmail.com-20110106225225-vvdxv468770vwng0
add pastebin.com support - bug 529195

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
                public static string PostUsing (IPastebinProvider pastebin)
34
34
                {
35
35
                        string url = null;
36
 
                        try
37
 
                        {
 
36
                        try {
38
37
                                string postQueryString = CreateQueryString (pastebin.Parameters);
39
38
                                
40
39
                                HttpWebRequest request = (HttpWebRequest)WebRequest.Create (pastebin.BaseUrl);
53
52
                                request.ContentLength = data.Length;
54
53
                                
55
54
                                using (Stream newStream = request.GetRequestStream ())
56
 
                                {
57
55
                                        newStream.Write(data, 0, data.Length);
58
 
                                }
59
56
                                
60
57
                                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
61
 
                                {                       
62
58
                                        url = pastebin.GetPasteUrlFromResponse (response);
63
 
                                }
64
 
                        }
65
 
                        catch (Exception e)
66
 
                        {
 
59
                        } catch (Exception e) {
67
60
                                Log<Pastebin>.Error (e.ToString ());
68
61
                                Services.Notifications.Notify ("Pastebin", "An error occured while pasting.");
69
62
                                url = null;
75
68
                private static string CreateQueryString (NameValueCollection query)
76
69
                {
77
70
                        StringBuilder queryString = new StringBuilder ();
78
 
                        foreach (string key in query.Keys)
79
 
                        {
 
71
                        foreach (string key in query.Keys) {
80
72
                                queryString.Append (HttpUtility.UrlEncode(key));
81
73
                                queryString.Append ("=");
82
74
                                queryString.Append (HttpUtility.UrlEncode(query[key]));