Main Area and Open Discussion > General Software Discussion
Source Code / Code Snippet Manager
wraith808:
One of the first things I notice is a lack of the ability to set your internet proxy. Without that, I can't use it to access snipplr. Do you have any intention of adding that ability?
mtelligent:
Good Point. I actually hadn't thought about setting up a proxy. I'll look into it tonight and see if it's something I can easily add support for.
wraith808:
I see you're using .NET. Not sure if it's C#, or what libraries you're using to connect, but if you're using the out of the box support and are using C#, here's an example of setting a proxy...
--- Code: C# ---var result = new StringBuilder(); try { var transferProxy = new WebProxy("http://proxy:80/", true); transferProxy.Credentials = new NetworkCredential("userId", "password", "Domain"); var transferRequest = WebRequest.Create("http://www.snipplr.com"); transferRequest.Proxy = transferProxy; HttpWebResponse transferResponse = (HttpWebResponse)transferRequest.GetResponse(); System.IO.Stream outputStream = transferResponse.GetResponseStream(); System.Text.Encoding outputEncoding = System.Text.Encoding.GetEncoding("utf-8"); System.IO.StreamReader outputReader = new System.IO.StreamReader(outputStream, outputEncoding); char[] chars = new Char[256]; int readCount = outputReader.Read(chars, 0, 256); int totalRead = readCount; while(readCount > 0) { string str = new String(chars, 0, 256); result.Append(str); readCount = outputReader.Read(chars, 0, 256); } transferResponse.Close(); outputStream.Close(); outputReader.Close(); } catch(Exception ex) { string str = ex.Message; }
Caveat- I pulled this from some other code and scrubbed some of the identifying lines, so there may be extraneous lines in there or it may not compile offhand, but the code is correct. Let me know if you have any questions, but it's pretty straightforward, and from what you've already done with snip-it, I'm sure it shouldn't be an issue. :Thmbsup:
UPDATE: Made sure it still compiled and fixed an embarrassing oversight.
mtelligent:
Snip-It Pro is written in C#.
The snipplr API is XML RPC so I am using the xmlrpc.net libraries at http://www.xml-rpc.net.
I can manually set the Proxy object like you described in your code snippet, or can just set it to the WebRequest.DefaultWebProxy which should (in theory) take the default proxy settings from Internet Explorer.
Would someone want to specify custom proxy settings for this one app, or just have it read the IE Settings?
wraith808:
I always allow a choice personally. There might be a reason not to use the default proxy, so I just put a radio button to allow (a) default proxies or (b) custom proxy. This also takes care of the case where IE won't play right, which I've had a problem with before.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version