我有时会在我的服务器日志中看到其中一个。
我想使用自定义重写映射处理请求标头。
因此,我想在环境变量中包含标头的内容。
我还没有找到用 mod_headers 和/或 mod_rewrite 做到这一点的方法。
任何帮助是appriciated。
我正在检查缓存在我的 Firefox 浏览器中的文件,我注意到其中的一些文件的过期时间 ( Expires:) 为:
"1970-01-01 00:00:00" expires header
Run Code Online (Sandbox Code Playgroud)
这必须是具有共同含义的共同设置。究竟是什么?没有设置过期?
有小费吗?
我只是(或不)试图从我的 Amazon 存储桶中强制下载 JPG,如下所示:
function get_s3_signed_url($bucket, $resource, $AWS_S3_KEY, $AWS_s3_secret_key, $expire_seconds) {
$expires = time()+$expire_seconds;
$string_to_sign = "GET\n\n\n{$expires}\n/".str_replace(".s3-eu-west-1.amazonAWS.com","", $bucket)."/$resource";
$signature = urlencode(base64_encode((hash_hmac("sha1", utf8_encode($string_to_sign), $AWS_s3_secret_key, TRUE))));
$authentication_params = "AWSAccessKeyId=".$AWS_S3_KEY;
$authentication_params.= "&Expires={$expires}";
$authentication_params.= "&Signature={$signature}";
return $link = "https://s3-eu-west-1.amazonAWS.com/{$bucket}/{$resource}?{$authentication_params}";
}
$url = get_s3_signed_url( $aws_bucketName, 'website-hires-photos/photo/'.$filename, $aws_access_key_id, $aws_s3_secret, 30);
header('Content-Type: images/jpg');
header("Content-Transfer-Encoding: Binary");
header('Content-Description: File Transfer');
header("Content-disposition: attachment; filename=\"".$url."\"");
readfile($url);
Run Code Online (Sandbox Code Playgroud)
但是我得到了很多行话,就像这样:
zóPcg”
îZ~ØsÍêïJ#£Aq$ÓÒ†Nkèk?Á+bÊ?«?k.?ªÄ‡K©˜‰?F?æÜv§›†??#kGGº~{ÖlüûË??¢¨Ü±S_?̧à??[Ô ?€??«ˆ/P?{ß“Ì?}_?k'?cg? UF–Ò[2kK\OÉá?¥'_PÓ?`oà?N‰ï?_?“Ûzöw4?í x©ì©”?—Œ£üä~¸˜ŸÓk£?¯Ö•á?w¨Â“ ÀÈ?äüÓ?÷9¨º—c?=üÿYò˜ä^€
这看起来很有趣,但我没有时间坐下来阅读。现在,文件“有点”下载,它说它的大小为 748kb,这是这张照片的正确大小。但是,我的机器不知道文件类型,所以我在文本编辑器中打开它,它给出了上述垃圾。
请告诉我我做错了什么。在这一点之前或之后,我没有在屏幕上回显任何内容。我在顶部有两个包含请求,这个函数和 headers 和 readfile 函数。
修复更新:
这完全是因为预签名的 AWS S3 链接在正确的.JPG 扩展名之后具有查询字符串值.JPG?AWSAccessKeyID=345wrdwf。因此,下载时,它无法识别扩展名。我通过为标题创建一个唯一的 …
尝试登录管理面板时遇到此错误。我无法理解它。
Warning: Cannot modify header information - headers already sent by (output started at /home/xxxxxx/public_html/wordpress/wp-config.php:1) in /home/xxxxxx/public_html/wordpress/wp-includes/pluggable.php on line 881
Run Code Online (Sandbox Code Playgroud)
pluggable.php 881:
function wp_redirect($location, $status = 302) {
global $is_IIS;
$location = apply_filters('wp_redirect', $location, $status);
$status = apply_filters('wp_redirect_status', $status, $location);
if ( !$location ) // allows the wp_redirect filter to cancel a redirect
return false;
$location = wp_sanitize_redirect($location);
if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )
status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location", true, …Run Code Online (Sandbox Code Playgroud) 假设我发现我的 Web 应用程序收到了明显是 SQL 注入攻击或类似攻击的请求。我编写了一个简短的测试来检查“顽皮”字符串的请求变量。如果我找到一个,我应该用什么代码来回应?
我正在考虑返回“403 Forbidden”并且没有内容,但我不确定。
内部 Web 应用程序中的自定义 http 标头是否有任何公认的命名约定?
严格意义上的内部意味着永远不会通过公共互联网传输具有此标头的请求。自由意义上的内部意味着虽然请求可以通过公共互联网传输,但服务器端点将始终是受特定供应商控制的机器。
然而,后一篇参考文献中提出的推理并不能完全说服我,因为它说:
2. SHOULD employ meaningful parameter names that they have reason to
believe are currently unused.
3. SHOULD NOT prefix their parameter names with "X-" or similar
constructs.
Run Code Online (Sandbox Code Playgroud)
好吧,X-<meaningful_name>传达了<meaningful_name>+ 所建议的语义,即此标头既未由官方标准维护机构分配也未向官方标准维护机构注册,因此第 2.、3. 项似乎有点矛盾。
当然,我可以使用其他绰号,例如Vnd-公司/产品名称前缀,甚至是像Foo-. X-然而,反对前缀的论点仍然适用。
另一方面,仅使用“有意义的名称”就会招致未来与官方标准或其他产品将成为加工管道一部分的公司认可的同一术语发生冲突。
ps:如果这个问题被认为过于不具体,请见谅。我很乐意把它搬到其他更合适的地方。
我需要创建一个具有特定名称的 Cookie,以便在我的 Web 服务调用中将其发送到另一个具有基于它的路由逻辑的网络。
当我尝试使用 SOAP 处理程序设置为 HTTP 标头时
headers.put("Cookie", Collections.singletonList(cookiename + "='" + cookieValue + "'"));
Run Code Online (Sandbox Code Playgroud)
它是第一次工作。
对此的响应带有JSESSIONID的Set-Cookie。
我随后的请求持有 JSESSIONID 和它在 cookie 中的值,并忽略设置我的自定义 cookie。
有没有办法确保在我的所有请求中默认设置我的 cookie?
我希望我的控制器在找不到模型时返回 404 响应,并且我想指定自定义消息,而不是默认的“ The requested controller was unable to dispatch the request.”
我尝试在reason中指定ViewModel,reasonPhrase从响应对象设置 ......似乎没有任何效果。我目前正在研究如何防止默认行为,但如果有人在我之前知道,那就太好了。(也许还有比我无论如何都能找到的更好的方法。)
这是我所拥有的,但不起作用:
$userModel = $this->getUserModel();
if (empty($userModel)) {
$this->response->setStatusCode(404);
$this->response->setReasonPhrase('error-user-not-found');
return new ViewModel(array(
'content' => 'User not found',
));
}
Run Code Online (Sandbox Code Playgroud)
谢谢。
我正在尝试这样做,但它不起作用。
class MyView(View):
def options(self, request, *args, **kwargs):
"""
Handles responding to requests for the OPTIONS HTTP verb.
"""
response = http.HttpResponse()
if self.kwargs.has_key('xml'):
response['Content-Type'] = 'text/xml; charset=utf-8'
return response
Run Code Online (Sandbox Code Playgroud) http-headers ×10
php ×4
http ×3
amazon-s3 ×1
apache ×1
apache2 ×1
caching ×1
cookies ×1
django ×1
firefox ×1
java ×1
mime-types ×1
mod-headers ×1
mod-rewrite ×1
pluggable ×1
soaphandler ×1
web-services ×1
wordpress ×1