Getting Google Image search to work within Rails

Hi,    I'm getting this strange behavior when I try to run search for images using Google Images API. I suspect it's because of my code and not the API itself, here's what I wrote:

    uri = URI.parse("https://ajax.googleapis.com/&quot;\)     http = Net::HTTP.new(uri.host, uri.port)     http.use_ssl = true     path = "ajax/services/search/images?v=1.0&q=gatsby&key=<key>"     path = URI.escape(path)     response = http.get(path, {"HTTP_REFERER" => "<my website>", 'User- Agent' => 'mozilla'})     data = response.body     result = JSON.parse(data)

I'm creating the HTTP object this way(with just the server, then calling the GET on the path) because I wanted to set the use_ssl flag explicitly.

The response I get is:

<HTML><HEAD><meta http-equiv="content-type" content="text/ html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved <A HREF="http://www.google.com">here</A>. </BODY></HTML>

When I try to access the same URL using curl, it works perfectly and returns a JSON object, so I know the data is not wrong. Any ideas?

Older discussions related to the Image search said that the URL was a plain HTTP url, it seems to have been changed to use HTTPS recently.

Thanks in advance !

Sudarshan