Hi everyone, I have a web app that at some point asks for a URL ... and i need to check that url''s validity ... is there a way to do that in RoR... - in C# i would to something along the lines of HttpWebRequest hReq (HttpWebRequest)WebRequest.Create(url................); HttpWebResponse hRes = (HttpWebResponse)hReq.GetResponse(); rCode = hRes.get_StatusCode()...etc Any input is greatly appreciated. Thank you, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I would say a lot depends on what criteria you are using to qualify a URL as valid. On Apr 4, 10:05 pm, "jimache" <vl_io...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hi everyone, > > I have a web app that at some point asks for a URL ... and i need to > check that url''s validity ... is there a way to do that in RoR... > - in C# i would to something along the lines of > > HttpWebRequest hReq > (HttpWebRequest)WebRequest.Create(url................); > > HttpWebResponse hRes = (HttpWebResponse)hReq.GetResponse(); > rCode = hRes.get_StatusCode()...etc > > Any input is greatly appreciated. > > Thank you,--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 5, 2007, at 6:53 AM, Erik wrote:> I would say a lot depends on what criteria you are using to qualify a > URL as valid. > > On Apr 4, 10:05 pm, "jimache" <vl_io...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: >> Hi everyone, >> >> I have a web app that at some point asks for a URL ... and i need to >> check that url''s validity ... is there a way to do that in RoR... >> - in C# i would to something along the lines of >> >> HttpWebRequest hReq >> (HttpWebRequest)WebRequest.Create(url................); >> >> HttpWebResponse hRes = (HttpWebResponse)hReq.GetResponse(); >> rCode = hRes.get_StatusCode()...etc >> >> Any input is greatly appreciated. >> >> Thank you,require ''uri'' def valid_uri? begin myuri = URI.parse(some_string_that_might_be_a_URL) rescue URI::InvalidURIError return false end # other checks on myuri.host or myuri.scheme to enforce application rules # return false if myuri.scheme =~ /javascript/i # etc. return true end Something like that? -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Apparently Analagous Threads
- [PATCH RFC 1/4] crypto: engine - Permit to enqueue all async requests
- [PATCH RFC 1/4] crypto: engine - Permit to enqueue all async requests
- Lighttpd & VB.Net HTTPWEBREQUEST
- [PATCH 2/6] crypto: engine - Permit to enqueue all async requests
- Using onlyif for Windows exec