http-head

Angular Jasmine - Test case gets failed in http HEAD request while on Flush

落花浮王杯 提交于 2019-12-11 19:45:28
问题 I'm trying to write a test case for the HTTP HEAD Request, it works fine without flush method. If I triggered the flush method the chrome browser gets disconnect. I don't know what needs to pass as a param to the flush method. Example: Service Method processData(id): void { const url = `http://localhost:5000/data/${id}`; this.http.head(url).subscribe(() => { console.log('Success'); // Rest of the code - TODO }, (error) => { console.log('Failed'); // Rest of the code - TODO }); } Test Case

Is the HEAD response faster than the GET?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 03:24:16
问题 I'm currently getting the info about the files with GET, will it be faster if I rewrite it using HEAD request? Cause I close the connection after the first response. 回答1: A HEAD response only includes the HTTP headers but no body - it is generally faster to just use a HEAD if you do not use any information in the body that would have normally transferred in a GET response - if there was no body to begin with it should not make a difference. Also from here: The HEAD method is identical to GET

Apache 2.2.2 response on HEAD requests

限于喜欢 提交于 2019-12-02 19:43:52
问题 Seems that Apache insists on removing the "Content-Length" header when sending a response to a HEAD request. Is there a way to configure it (or code it in PHP) to send "Content-Length: 0" for such responses? For some weird reason it breaks the client (which is not under my control). 回答1: One thing to look at would be mod_filter config. Look in modules/http/http_filters . Apache sends Content-Length by default, your host or environment may have disabled. You might have better luck with this

Making HTTP HEAD request with timeout in Ruby

不打扰是莪最后的温柔 提交于 2019-12-02 03:23:54
问题 In a Rails app, I'd like to make a HTTP HEAD request for a resource (a user-provided URL), to make sure that it exists. I'd also like a timeout, to ensure that the method fails after spending a reasonable period of time waiting. What is the most straightforward way to accomplish this (using the standard library, if possible)? 回答1: Try this snippet: require 'net/http' Net::HTTP.start('www.some_site.com') do |http| http.open_timeout = 2 http.read_timeout = 2 req = Net::HTTP::Head.new('/') http

Making HTTP HEAD request with timeout in Ruby

人盡茶涼 提交于 2019-12-02 02:33:34
In a Rails app, I'd like to make a HTTP HEAD request for a resource (a user-provided URL), to make sure that it exists. I'd also like a timeout, to ensure that the method fails after spending a reasonable period of time waiting. What is the most straightforward way to accomplish this (using the standard library, if possible)? Try this snippet: require 'net/http' Net::HTTP.start('www.some_site.com') do |http| http.open_timeout = 2 http.read_timeout = 2 req = Net::HTTP::Head.new('/') http.request(req).each { |k, v| puts "#{k}: #{v}" } end Hope this is what you're looking for. UPDATE Because

Is the HEAD response faster than the GET?

随声附和 提交于 2019-12-01 17:40:53
I'm currently getting the info about the files with GET, will it be faster if I rewrite it using HEAD request? Cause I close the connection after the first response. A HEAD response only includes the HTTP headers but no body - it is generally faster to just use a HEAD if you do not use any information in the body that would have normally transferred in a GET response - if there was no body to begin with it should not make a difference. Also from here : The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the

Correct response to HTTP HEAD Request on HTTPS only site

空扰寡人 提交于 2019-12-01 00:31:51
问题 We have an ASP.Net MVC3 site only accessible over HTTPS, by using the RequireHTTPS attribute on the controller. We are receiving numerous HTTP HEAD method requests, mainly from what appear to be Twitter bots. The default ASP.Net/MVC3 response is a '500 Internal Server Error', and are being caught/logged by elmah and log4net (now filtered out!). I could write a specific controller and route to handle these non-HTTPS requests as per this question - Responding to HEAD Request in asp.NET MVC 3.

Respond to HTTP HEAD requests using ASP.NET MVC

强颜欢笑 提交于 2019-11-29 05:24:51
I'd like to correctly support the HTTP HEAD request when bots hit my ASP.NET MVC site using HEAD. It was brought to my attention that all HTTP HEAD requests to the site were returning 404s, particularly from http://downforeveryoneorjustme.com . Which is really annoying. Wish they would switch to GET like all the other good bots out there. If I just change [AcceptVerbs(HttpVerbs.Get)] to [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)] will MVC know to drop the body of the request? What have you done to support HTTP HEAD requests? (Code sample would be great!) I created a simple action method in

Checking if a website is up via Python

浪尽此生 提交于 2019-11-28 16:11:09
By using python, how can I check if a website is up? From what I read, I need to check the "HTTP HEAD" and see status code "200 OK", but how to do so ? Cheers Related How do you send a HEAD HTTP request in Python? Anthony Forloney You could try to do this with getcode() from urllib >>> print urllib.urlopen("http://www.stackoverflow.com").getcode() >>> 200 EDIT: For more modern python, i.e. python3 , use: import urllib.request print(urllib.request.urlopen("http://www.stackoverflow.com").getcode()) >>> 200 I think the easiest way to do it is by using Requests module. import requests def url_ok

Respond to HTTP HEAD requests using ASP.NET MVC

不羁的心 提交于 2019-11-27 22:56:42
问题 I'd like to correctly support the HTTP HEAD request when bots hit my ASP.NET MVC site using HEAD. It was brought to my attention that all HTTP HEAD requests to the site were returning 404s, particularly from http://downforeveryoneorjustme.com. Which is really annoying. Wish they would switch to GET like all the other good bots out there. If I just change [AcceptVerbs(HttpVerbs.Get)] to [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Head)] will MVC know to drop the body of the request? What have you