473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ContentType detection without full downloading

'm using HttpWebRequest/Response to get content type of urls (a lot of them)
It takes a while, so is it possible to tell to request/response just get a
content type (download only headers) ?

TNX

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
Nov 16 '05 #1
2 2059
"Tamir Khason" wrote:
'm using HttpWebRequest/Response to get content type of urls (a lot of
them)
It takes a while, so is it possible to tell to request/response just get a
content type (download only headers) ?

HTTP defines a 'HEAD' verb for just this purpose. The meaning of the 'HEAD'
verb is basically "Please show me all the headers you would have given me if
I'd done a GET for this URL." So something like this:

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(http://foo/bar);
req.Method = "HEAD";

...
The one caveat is that you sometimes find that HEAD isn't supported. Most
web sites support it, but it's occasionally broken, so you might need to
fall back to a normal GET in failure cases.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/
Nov 16 '05 #2
It's just what I need, Thank you !

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "

"Ian Griffiths [C# MVP]" <ia*************@nospam.nospam> wrote in message
news:e2**************@TK2MSFTNGP15.phx.gbl...
"Tamir Khason" wrote:
'm using HttpWebRequest/Response to get content type of urls (a lot of
them)
It takes a while, so is it possible to tell to request/response just get
a content type (download only headers) ?

HTTP defines a 'HEAD' verb for just this purpose. The meaning of the
'HEAD' verb is basically "Please show me all the headers you would have
given me if I'd done a GET for this URL." So something like this:

HttpWebRequest req = (HttpWebRequest) WebRequest.Create(http://foo/bar);
req.Method = "HEAD";

...
The one caveat is that you sometimes find that HEAD isn't supported. Most
web sites support it, but it's occasionally broken, so you might need to
fall back to a normal GET in failure cases.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
2
by: cwdjr | last post by:
Real One has a page to copy on their site that detects if the browser of a viewer of a page has Real One installed. The page is located at...
7
by: Michael Winter | last post by:
As many of you know, IE has poor support for CSS 2, including the dynamic pseudo-class, :hover. This could easily be emulated with an intrinsic event, but how can you tell that it's required? You...
26
by: Raffi | last post by:
Hi, We have a database application that runs in a popup Internet Explorer application window. The reason for this is to isolate the casual user from the address bar and the typical IE navigation...
8
by: Bryan Glennon | last post by:
I have an aspx page. If I set the Response.ContentType = "application/voicexml+xml" then when I load browse to the page it downloads the file and opens .Net Studio to allow me to edit it. It...
2
by: CVerma | last post by:
I'm using an html input control (System.web.UI.HTMLControls.HTMLInputFile) to upload files such as msword, excel, jpg, and pdf. I have the encType property set in the form:...
21
by: nsimeonov | last post by:
Hello, Does anyone have any idea how Gmail does this? I have a web application and people complain sometimes about some problems and most of the time it turns out it's the browser's cache...
1
by: gts | last post by:
Hello, I'm putting together a page with some links to videos. One link plays the video and the other is supposed to allow the user to download the file by forcing the "save as" box. For the download...
4
by: Bjorn Sagbakken | last post by:
With ASP.NET 2.0 I'm trying to display the pdf file directly in the client browser, but I only get a download dialogue box. Downloading the file works fine, but I want to view the PDF directly. ...
10
by: Conrad Lender | last post by:
In a recent thread in this group, I said that in some cases object detection and feature tests weren't sufficient in the development of cross-browser applications, and that there were situations...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.