# Download only http headers

**URL:** <https://www.ruby-forum.com/t/download-only-http-headers/77727>\
**Category:** Ruby\
**Created:** [November 30, 2006, 1:32am UTC](https://www.ruby-forum.com/t/download-only-http-headers/77727 "2006-11-30T01:32:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nguyen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nguyen](https://www.ruby-forum.com/u/nguyen)\
**Post date:** [November 30, 2006, 1:32am UTC](https://www.ruby-forum.com/t/download-only-http-headers/77727/1 "2006-11-30T01:32:04Z")

</div>

Hi folks,

I’m writing a small app which needs to list all HTML pages (only HTML  
pages, no image, no CSS, pdf, gif etc.) from a starting page. Given  
any link, I use Net::HTTP to download the content and examine the  
content-type header in order to determine whether it is a HTML page or  
s/t else (I don’t think pattern matching will work because there are  
dynamic pages being able to return arbitrary resources [HTML, images  
etc.]); however, I cannot find anyway to only read the headers without  
reading the whole contents of that resource (e.g. a PDF). That would  
make my app perform very slowly while all I want is just listing the  
HTML pages.

Does anyone have any suggestion as to how this problem can be solved?

Thanks in advance

Nguyen

---

<div class="post-metadata">

**Author:** ![nguyen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nguyen](https://www.ruby-forum.com/u/nguyen)\
**Post date:** [November 30, 2006, 1:46am UTC](https://www.ruby-forum.com/t/download-only-http-headers/77727/2 "2006-11-30T01:46:05Z")

</div>

Nguyen wrote:

> 

Net::HTTP has the ability to do HEAD commands in addition to GET. You  
can get the headers that way.

Tom

---

<div class="post-metadata">

**Author:** ![nguyen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nguyen](https://www.ruby-forum.com/u/nguyen)\
**Post date:** [November 30, 2006, 3:10am UTC](https://www.ruby-forum.com/t/download-only-http-headers/77727/3 "2006-11-30T03:10:17Z")

</div>

Work like charm. Thanks a great deal, Tom.

Nguyen
