Hi, For an app I need users to put in the domain name their website is hosted on. It''s important that this domain works, so I''d like my app to check this. I''d like to be able to process the response. If it returns a 404 error or maybe even a 500 error I''d like it to have the method return true, but also a message saying there''s something the user needs to look into at their end. If the domain is unavailable (so there is no record in the zonefile) I''d like the method to return false and return an error message saying the domain is invalid. Of course, if it passes with a 200 message, I''d like it to return true and a success message. Is this possible and how? Thank you very much!
On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > For an app I need users to put in the domain name their website is > hosted on. It''s important that this domain works, so I''d like my app > to check this. I''d like to be able to process the response. If it > returns a 404 error or maybe even a 500 error I''d like it to have the > method return true, but also a message saying there''s something the > user needs to look into at their end. If the domain is unavailable (so > there is no record in the zonefile) I''d like the method to return > false and return an error message saying the domain is invalid. Of > course, if it passes with a 200 message, I''d like it to return true > and a success message. > > Is this possible and how? >Well you could use the ruby name resolving classes or make an http request with Net::HTTP (although beware of DNS servers that lie when the domain doesn''t exist) Fred> Thank you very much!
I''m not behind it right now, but would the following work? require ''net/http'' url = URI.parse(params[:url]) http = Net::HTTP.new(url.host, url.port) response = http.send_request(''GET'', ''/'') puts response.body Thank you. On 19 okt, 20:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > For an app I need users to put in the domain name their website is > > hosted on. It''s important that this domain works, so I''d like my app > > to check this. I''d like to be able to process the response. If it > > returns a 404 error or maybe even a 500 error I''d like it to have the > > method return true, but also a message saying there''s something the > > user needs to look into at their end. If the domain is unavailable (so > > there is no record in the zonefile) I''d like the method to return > > false and return an error message saying the domain is invalid. Of > > course, if it passes with a 200 message, I''d like it to return true > > and a success message. > > > Is this possible and how? > > Well you could use the ruby name resolving classes or make an http > request with Net::HTTP (although beware of DNS servers that lie when > the domain doesn''t exist) > > Fred > > > Thank you very much! > >
On Oct 19, 7:35 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m not behind it right now, but would the following work? > > require ''net/http'' > > url = URI.parse(params[:url]) > http = Net::HTTP.new(url.host, url.port) > response = http.send_request(''GET'', ''/'') > puts response.body >well it would check you can make a request to that domain (assuming no dns tomfoolery), obviously doesn''t check if there is any thing valid at that url Fred> Thank you. > > On 19 okt, 20:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > > For an app I need users to put in the domain name their website is > > > hosted on. It''s important that this domain works, so I''d like my app > > > to check this. I''d like to be able to process the response. If it > > > returns a 404 error or maybe even a 500 error I''d like it to have the > > > method return true, but also a message saying there''s something the > > > user needs to look into at their end. If the domain is unavailable (so > > > there is no record in the zonefile) I''d like the method to return > > > false and return an error message saying the domain is invalid. Of > > > course, if it passes with a 200 message, I''d like it to return true > > > and a success message. > > > > Is this possible and how? > > > Well you could use the ruby name resolving classes or make an http > > request with Net::HTTP (although beware of DNS servers that lie when > > the domain doesn''t exist) > > > Fred > > > > Thank you very much!
Of course not, but it will give a 404 if there''s nothing there, for example? That''s what matters What would be the response if you check for an inactive domain? Is that simply no response at all? Because that could also mean it times out, no? I know it''s not 100% safe, the user also has some responsibility. Even a typo that resolves could validate, I have some other ideas for that, but I''d like to take out the 404s, 500s and what not. Thanks again. On 19 okt, 22:39, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 19, 7:35 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m not behind it right now, but would the following work? > > > require ''net/http'' > > > url = URI.parse(params[:url]) > > http = Net::HTTP.new(url.host, url.port) > > response = http.send_request(''GET'', ''/'') > > puts response.body > > well it would check you can make a request to that domain (assuming no > dns tomfoolery), obviously doesn''t check if there is any thing valid > at that url > > Fred > > > Thank you. > > > On 19 okt, 20:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > > > For an app I need users to put in the domain name their website is > > > > hosted on. It''s important that this domain works, so I''d like my app > > > > to check this. I''d like to be able to process the response. If it > > > > returns a 404 error or maybe even a 500 error I''d like it to have the > > > > method return true, but also a message saying there''s something the > > > > user needs to look into at their end. If the domain is unavailable (so > > > > there is no record in the zonefile) I''d like the method to return > > > > false and return an error message saying the domain is invalid. Of > > > > course, if it passes with a 200 message, I''d like it to return true > > > > and a success message. > > > > > Is this possible and how? > > > > Well you could use the ruby name resolving classes or make an http > > > request with Net::HTTP (although beware of DNS servers that lie when > > > the domain doesn''t exist) > > > > Fred > > > > > Thank you very much! > >
On Oct 20, 8:52 am, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Of course not, but it will give a 404 if there''s nothing there, for > example? That''s what matters > > What would be the response if you check for an inactive domain? Is > that simply no response at all? Because that could also mean it times > out, no? I know it''s not 100% safe, the user also has some > responsibility. Even a typo that resolves could validate, I have some > other ideas for that, but I''d like to take out the 404s, 500s and what > not. >If a domain doesn''t resolve at all you should get an error to that effect. After that, all depends on your definition of inactive and valid. For example is a ''you have successfully installed apache'' page valid ? Is a domain parking page valid ? Fred> Thanks again. > > On 19 okt, 22:39, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Oct 19, 7:35 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m not behind it right now, but would the following work? > > > > require ''net/http'' > > > > url = URI.parse(params[:url]) > > > http = Net::HTTP.new(url.host, url.port) > > > response = http.send_request(''GET'', ''/'') > > > puts response.body > > > well it would check you can make a request to that domain (assuming no > > dns tomfoolery), obviously doesn''t check if there is any thing valid > > at that url > > > Fred > > > > Thank you. > > > > On 19 okt, 20:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > > > > For an app I need users to put in the domain name their website is > > > > > hosted on. It''s important that this domain works, so I''d like my app > > > > > to check this. I''d like to be able to process the response. If it > > > > > returns a 404 error or maybe even a 500 error I''d like it to have the > > > > > method return true, but also a message saying there''s something the > > > > > user needs to look into at their end. If the domain is unavailable (so > > > > > there is no record in the zonefile) I''d like the method to return > > > > > false and return an error message saying the domain is invalid. Of > > > > > course, if it passes with a 200 message, I''d like it to return true > > > > > and a success message. > > > > > > Is this possible and how? > > > > > Well you could use the ruby name resolving classes or make an http > > > > request with Net::HTTP (although beware of DNS servers that lie when > > > > the domain doesn''t exist) > > > > > Fred > > > > > > Thank you very much!
Well, it''s not actually valid, but we only want to filter out the bogus domains. All the other ones will be validated manually, because you simply can''t catch everything. It will be trial and error for the most part. Later on we might, for example, check its content or maybe even nameservers (nsx.sedoparking.com could be rejected by default). What I want for the moment is to reject a domain that''s not even registered and maybe later also any errors like 404 and 500. On 20 okt, 10:19, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 20, 8:52 am, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Of course not, but it will give a 404 if there''s nothing there, for > > example? That''s what matters > > > What would be the response if you check for an inactive domain? Is > > that simply no response at all? Because that could also mean it times > > out, no? I know it''s not 100% safe, the user also has some > > responsibility. Even a typo that resolves could validate, I have some > > other ideas for that, but I''d like to take out the 404s, 500s and what > > not. > > If a domain doesn''t resolve at all you should get an error to that > effect. After that, all depends on your definition of inactive and > valid. For example is a ''you have successfully installed apache'' page > valid ? Is a domain parking page valid ? > > Fred > > > Thanks again. > > > On 19 okt, 22:39, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Oct 19, 7:35 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I''m not behind it right now, but would the following work? > > > > > require ''net/http'' > > > > > url = URI.parse(params[:url]) > > > > http = Net::HTTP.new(url.host, url.port) > > > > response = http.send_request(''GET'', ''/'') > > > > puts response.body > > > > well it would check you can make a request to that domain (assuming no > > > dns tomfoolery), obviously doesn''t check if there is any thing valid > > > at that url > > > > Fred > > > > > Thank you. > > > > > On 19 okt, 20:18, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > On Oct 19, 6:59 pm, jhaagmans <jaap.haagm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > > > > > > For an app I need users to put in the domain name their website is > > > > > > hosted on. It''s important that this domain works, so I''d like my app > > > > > > to check this. I''d like to be able to process the response. If it > > > > > > returns a 404 error or maybe even a 500 error I''d like it to have the > > > > > > method return true, but also a message saying there''s something the > > > > > > user needs to look into at their end. If the domain is unavailable (so > > > > > > there is no record in the zonefile) I''d like the method to return > > > > > > false and return an error message saying the domain is invalid. Of > > > > > > course, if it passes with a 200 message, I''d like it to return true > > > > > > and a success message. > > > > > > > Is this possible and how? > > > > > > Well you could use the ruby name resolving classes or make an http > > > > > request with Net::HTTP (although beware of DNS servers that lie when > > > > > the domain doesn''t exist) > > > > > > Fred > > > > > > > Thank you very much!