# Too slow in using Net::HTTP.post\_form

**URL:** <https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912>\
**Category:** Ruby\
**Created:** [August 13, 2007, 11:52am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912 "2007-08-13T11:52:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 13, 2007, 11:52am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/1 "2007-08-13T11:52:50Z")

</div>

Hi

I am using Net::HTTP.post\_form to post cgi request to a website and get  
answers.  
Below is my code and I found that it always take about 30s to return the  
result. I think my Internt connection is not so slow as I paste the same  
cgi request url and run in my firefox, it will get result in less then  
10 second.

puts Time.now  
post\_result= Net::HTTP.post\_form(URI.parse(url),params)  
puts Time.now

So, how can I make the post\_form returns quickly?  
And, I also found many tags like ![]() in the returned html  
file. Did the post\_form download all those gif files? If so, how can I  
discard all the image file and only get the text result?

Thanks in advance.

ak

---

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 14, 2007, 2:37am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/2 "2007-08-14T02:37:14Z")

</div>

So bad, no one can give me some hint?

---

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 14, 2007, 2:49am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/3 "2007-08-14T02:49:35Z")

</div>

On Aug 13, 2007, at 7:37 PM, Ak 756 wrote:

> ## So bad, no one can give me some hint?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

You might post more of the code.

---

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 14, 2007, 12:58pm UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/4 "2007-08-14T12:58:33Z")

</div>

Ak 756 wrote the following on 13.08.2007 11:52 :

> post\_result= Net::HTTP.post\_form(URI.parse(url),params)  
> puts Time.now
> 
> So, how can I make the post\_form returns quickly?

Maybe the particular server you are testing reacts differently if you  
don’t have a session, a referer or the right user-agent ?

> And, I also found many tags like ![]() in the returned html  
> file. Did the post\_form download all those gif files?

No, it didn’t.

---

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 15, 2007, 3:27am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/5 "2007-08-15T03:27:54Z")

</div>

Lionel B. wrote:

> Ak 756 wrote the following on 13.08.2007 11:52 :
> 
> > post\_result= Net::HTTP.post\_form(URI.parse(url),params)  
> > puts Time.now
> > 
> > So, how can I make the post\_form returns quickly?
> 
> Maybe the particular server you are testing reacts differently if you  
> don’t have a session, a referer or the right user-agent ?
> 
> > And, I also found many tags like ![]() in the returned html  
> > file. Did the post\_form download all those gif files?
> 
> No, it didn’t.

Hi

## Below is my code:

require ‘net/http’

## params = {‘s’=\>‘GOOG’} url=‘[http://finance.yahoo.com/q](http://finance.yahoo.com/q)’ puts Time.now post\_result= Net::HTTP.post\_form(URI.parse(url),params) puts Time.now

And its running result:  
Wed Aug 15 09:11:48 +0800 2007  
Wed Aug 15 09:12:02 +0800 2007

I think this is slow since the post\_form will not downloading pictures  
in the post reply page. And when I type the url  
‘[http://finance.yahoo.com/q?s=GOOG](http://finance.yahoo.com/q?s=GOOG)’ in my firefox , it will show the  
complete page including pictures in about 10s. If I configure the  
firefox to not download pictures, it need only 4s. So,how I can I make  
post\_form reply more fast?

---

<div class="post-metadata">

**Author:** ![ak756](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b5a626/32.png) [@ak756](https://www.ruby-forum.com/u/ak756)\
**Post date:** [August 15, 2007, 3:34am UTC](https://www.ruby-forum.com/t/too-slow-in-using-net-http-post-form/111912/6 "2007-08-15T03:34:27Z")

</div>

On 8/14/07, Ak 756 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And its running result:  
> Wed Aug 15 09:11:48 +0800 2007  
> Wed Aug 15 09:12:02 +0800 2007
> 
> I think this is slow since the post\_form will not downloading pictures  
> in the post reply page. And when I type the url  
> ‘[Alphabet Inc. (GOOG) Stock Price, News, Quote & History - Yahoo Finance](http://finance.yahoo.com/q?s=GOOG)’ in my firefox , it will show the  
> complete page including pictures in about 10s. If I configure the  
> firefox to not download pictures, it need only 4s. So,how I can I make  
> post\_form reply more fast?

The same code takes less than a second for me. Perhaps it is your  
connection?
