http-headers

Is it possible to send values to controller from middleware in aspnet core api?

*爱你&永不变心* 提交于 2020-01-13 16:22:08
问题 I want to know if is it possible to send value from middleware to controllerAPI ? For example, I want catch one particular header and send to the controller. Something like that : public class UserTokenValidatorsMiddleware { private readonly RequestDelegate _next; //private IContactsRepository ContactsRepo { get; set; } public UserTokenValidatorsMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { if (!context.Request.Path.Value.Contains("auth"))

How to set HttpHeader on individual request using HttpClient

天涯浪子 提交于 2020-01-13 10:22:13
问题 I have an HttpClient that is shared across multiple threads: public static class Connection { public static HttpClient Client { get; } static Connection() { Client = new HttpClient { BaseAddress = new Uri(Config.APIUri) }; Client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); Client.DefaultRequestHeaders.Add("Keep-Alive", "timeout=600"); Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } } It has some default headers I put onto each

What is the definition of HTTP_X_PURPOSE?

*爱你&永不变心* 提交于 2020-01-13 08:20:34
问题 Recently we've been looking at a few exceptions captured in our Stack Overflow logs and have discovered an issue for Safari users. I noticed this HTTP header in one of the exceptions we have captured: HTTP_X_PURPOSE preview Does anyone know what action triggers this header or the meaning of HTTP_X_PURPOSE? 回答1: The "X-Purpose: preview" header is definitely a Safari 4 top sites thing. The Top Sites page tries to show a live-ish thumbnail of the favourite pages. If favourite page is open in a

How to identify curl request

依然范特西╮ 提交于 2020-01-13 06:41:09
问题 Is there a way to detect in my script whether the request is coming from normal web browser or some script executing curl. I can see the headers and can distinguish with "User-Agent and other few headers" but in curl fake headers can be set, so i am not able to track the request. Please suggest me ways about identifying the curl or other similar non browser request. 回答1: The only way to catch most "automated" requests is to code in logic that spots activity that couldn't possibly be human

Add custom headers to IMG, VIDEO and AUDIO requests

点点圈 提交于 2020-01-12 18:48:34
问题 I am working on a project where we need to add some custom headers to the HTTP requests for image, video and audio content in the browser. I've been looking around and not really coming up with a good answer, other than possibly creating browser plugins. Decorating the URL is not an option at this time because the gateway is looking for headers. I can get the content by AJAX requests and adding the header to AJAX requests, then reassembling the content, base64 encoding it, then feeding that

Add custom headers to IMG, VIDEO and AUDIO requests

你离开我真会死。 提交于 2020-01-12 18:47:02
问题 I am working on a project where we need to add some custom headers to the HTTP requests for image, video and audio content in the browser. I've been looking around and not really coming up with a good answer, other than possibly creating browser plugins. Decorating the URL is not an option at this time because the gateway is looking for headers. I can get the content by AJAX requests and adding the header to AJAX requests, then reassembling the content, base64 encoding it, then feeding that

Add custom headers to IMG, VIDEO and AUDIO requests

眉间皱痕 提交于 2020-01-12 18:46:10
问题 I am working on a project where we need to add some custom headers to the HTTP requests for image, video and audio content in the browser. I've been looking around and not really coming up with a good answer, other than possibly creating browser plugins. Decorating the URL is not an option at this time because the gateway is looking for headers. I can get the content by AJAX requests and adding the header to AJAX requests, then reassembling the content, base64 encoding it, then feeding that

Can I pass custom data in the HTTP header?

自闭症网瘾萝莉.ら 提交于 2020-01-12 12:55:07
问题 I have a whole bunch of web services each with several web methods. The consumers of these services are varied and many. I want to augment each of these web methods with an extra optional parameter (Int64 or Int32) but adding new methods with this extra (optional parameter) is a lot of work and getting the clients to use the new methods will be even more time consuming. So I was wondering if I could allow the clients that wanted to take advantage of the new feature that this param provides

Can I pass custom data in the HTTP header?

半腔热情 提交于 2020-01-12 12:51:05
问题 I have a whole bunch of web services each with several web methods. The consumers of these services are varied and many. I want to augment each of these web methods with an extra optional parameter (Int64 or Int32) but adding new methods with this extra (optional parameter) is a lot of work and getting the clients to use the new methods will be even more time consuming. So I was wondering if I could allow the clients that wanted to take advantage of the new feature that this param provides

How to download a file using php?

左心房为你撑大大i 提交于 2020-01-12 09:56:30
问题 I want to download file from my server using php. I searched google and found a stackoverflow answer here. This answer shows that I have to write these codes for this purpose. $file_url = 'http://www.myremoteserver.com/file.exe'; header('Content-Type: application/octet-stream'); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\""); readfile($file_url); But I am able to do this with merely these two lines: header(