http-headers

Is safe to use “X-…” header in a HTTP response?

我与影子孤独终老i 提交于 2019-12-18 03:51:06
问题 I have to pass a meta-information in my HTTP response so I figured out that I could use the response header, for instance "X-MyData: 123456". Is that safe? I mean, there is a possibility that a client proxy remove this header? Thanks! 回答1: A client proxy could do anything it wanted, but in general would not strip any headers. Headers starting with an X- are typically reserved for nonstandard usage (i.e. no future standard will introduce a header starting X-) but a proxy may understand them

Are HTTP headers (Content-Type, &c.) case-sensitive? [duplicate]

夙愿已清 提交于 2019-12-18 03:48:09
问题 This question already has answers here : Are HTTP headers case-sensitive? (6 answers) Closed 5 years ago . Perhaps I'm skimming too fast, but couldn't find this specifically documented. In my particular case, I'm wondering about the "Content-Type" header, but I'm assuming the same rules would apply to other standard headers. Are these case sensitive, and if so: Is it Content-Type or Content-type ? Is there a proper place to reference these? 回答1: Case-insensitive. Hypertext Transfer Protocol -

Rack::Request - how do I get all headers?

送分小仙女□ 提交于 2019-12-18 01:26:06
问题 The title is pretty self-explanatory. Is there any way to get the headers (except for Rack::Request.env[] )? 回答1: The HTTP headers are available in the Rack environment passed to your app: HTTP_ Variables: Variables corresponding to the client-supplied HTTP request headers (i.e., variables whose names begin with HTTP_). The presence or absence of these variables should correspond with the presence or absence of the appropriate HTTP header in the request. So the HTTP headers are prefixed with

HTTP Authentication in Python

只愿长相守 提交于 2019-12-17 23:23:59
问题 Whats is the python urllib equivallent of curl -u username:password status="abcd" http://example.com/update.json I did this: handle = urllib2.Request(url) authheader = "Basic %s" % base64.encodestring('%s:%s' % (username, password)) handle.add_header("Authorization", authheader) Is there a better / simpler way? 回答1: The trick is to create a password manager, and then tell urllib about it. Usually, you won't care about the realm of the authentication, just the host/url part. For example, the

PHP / Curl: HEAD Request takes a long time on some sites

╄→尐↘猪︶ㄣ 提交于 2019-12-17 23:21:11
问题 I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete. For example, requesting http://www.arstechnica.com takes about two minutes. I've tried the same request using another web site that does the same basic task, and it comes back immediately. So there must be something I have set incorrectly that's causing this delay. Here's the code I have: $ch = curl_init(); curl_setopt ($ch,

PHP script to download file not working in IE

杀马特。学长 韩版系。学妹 提交于 2019-12-17 23:08:13
问题 I have a script that takes a key from $_GET['key'] , looks up the location in a database and uses the readfile together with some headers to present a download for the use. This works in Firefox but not IE8, haven't been able to test it on another IE. I get the following error in IE: "Internet Explorer cannot download download.php from www.example.com". As if it is trying to download the PHP script. $the_query = "SELECT * FROM `files` WHERE `user_id`=" . $_SESSION['user_id'] . " AND `key`='"

Header parameters: “Accept” and “Content-type” in a REST context

懵懂的女人 提交于 2019-12-17 22:48:00
问题 I understand that the Accept parameter define a data type expected in a client response sent from the server, so it's used as a response header. My question is regarding the Content-type , it's used by a client to define the body format of a request sent, I always used it as part of a client request, so I have a client request where I set the headers with Accept and Content-type . And recently, I came across a project where the Content-type is defined in the response headers (so sent by the

What header should be used for sending GZIP compressed JSON from Android Client to Server?

狂风中的少年 提交于 2019-12-17 22:45:20
问题 This question is extension to the question here. I am using the code here reproduced below to GZIP compress a JSONObject . String foo = "value"; ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = null; try { gzos = new GZIPOutputStream(baos); gzos.write(foo.getBytes("UTF-8")); } finally { if (gzos != null) try { gzos.close(); } catch (IOException ignore) {}; } byte[] fooGzippedBytes = baos.toByteArray(); I am using a DefaultHttpClient to send this compressed

Do HTTP proxy servers modify request packets?

梦想与她 提交于 2019-12-17 22:40:26
问题 Is any request header added or modified to the HTTP request before forwarding to the server by a proxy server? If so, are the changes done to the same packets, or are the contents used to create new request packets with the modifications? 回答1: There are a few different types of proxy servers. Because you've mentioned request headers, I'm going to assume that you're talking about HTTP proxy servers, which forward HTTP requests, not packets. NOTE: In the special case of HTTPS requests (TLS/SSL

Passing headers and query params in HTTparty

主宰稳场 提交于 2019-12-17 22:38:30
问题 How to pass query params and headers in post method using HTTparty. I am doing as follows But it throws query = {:method => "neworder", :nonce => 1404996028, :order_type => "buy", :quantity=>1,:rate=>1} headers = {:key=> "87819747209090199871234", :sign=> "0a3888ac7f8e411ad73a0a503c55db70a291rsf34bfb9f9a47147d5200882674f717f6ede475669f3453"} HTTParty.post("https://www.acb.com/api/v2/market/LTC_BTC/", :query => query, :headers => headers ) But it throws the following error. How to handle query