我正在开发社交网络的应用程序.当我尝试访问它时,我的浏览器出错:
拒绝显示文档,因为X-Frame-Options禁止显示.
此社交网络使用Iframe.我的问题是,如何更改标题来解决此问题?
考虑克服"X-Frame-Options禁止显示",在我的servlet中我尝试了命令:
httpServletResponse.addHeader("X-FRAME-OPTIONS", "SAMEORIGIN" );
Run Code Online (Sandbox Code Playgroud)
考虑到http://www.rivercitystudio.com/blog/2011/09/google-maps-embedding-x-frame-options-change/我也尝试在我的网址中添加以下内容:
&output=embed
Run Code Online (Sandbox Code Playgroud)
这两种选择都没有奏效.
我可以安全地在PHP重定向头中使用已发布的值而不检查它:
header( "Location: $base".$_POST['return'] ); // $base is set to the base of the site
Run Code Online (Sandbox Code Playgroud)
(如果用户以某种方式操作return到不存在的文件,它只会返回一条很好的404消息)
这样做有危险吗?用户是否可以将其设置为可能危及系统或以任何方式损坏?
我正在尝试编写重定向检查程序,以检查URL是否对搜索引擎友好.它必须检查URL是否被重定向,如果它被重定向,它必须告诉它是否是SEO友好(301状态代码)或不(302/304).
这是我发现的类似内容:http://www.webconfs.com/redirect-check.php
它也应该能够遵循多个重定向(例如从A到B到C)并告诉我A重定向到C.
这是我到目前为止所做的,但它不能正常工作(例如:在www.example.com上输入时,它没有找到重定向到www.example.com/page1)
<?php
// You can edit the messages of the respective code over here
$httpcode = array();
$httpcode["200"] = "Ok";
$httpcode["201"] = "Created";
$httpcode["302"] = "Found";
$httpcode["301"] = "Moved Permanently";
$httpcode["304"] = "Not Modified";
$httpcode["400"] = "Bad Request";
if(count($_POST)>0)
{
$url = $_POST["url"];
$curlurl = "http://".$url."/";
$ch = curl_init();
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $curlurl);
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
// Include header in result? (0 = yes, 1 = no) …Run Code Online (Sandbox Code Playgroud) 我有一个注册用户的Web服务和Web界面.此部分允许用户获取其统计信息(类似于堆栈溢出)
现在这个工具我允许用户以json格式检索他们的数据,我的问题是发送的标题不适用于所有浏览器
我有:
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 00:00:00 GMT');
header('Content-type: text/json');
Run Code Online (Sandbox Code Playgroud)
我应该删除过期和缓存控制?
我正在使用meltice的TwitPic API,当我尝试上传图片时,我收到401错误,上面写着 "无法验证您的身份(标题被Twitter拒绝)".
我的标头(从HTTP Request2对象中检索)是:
Array
(
[user-agent] => HTTP_Request2/2.0.0 (http://pear.php.net/package/http_request2) PHP/5.2.17
[x-verify-credentials-authorization] => OAuth realm="http://api.twitter.com/", oauth_consumer_key="****************", oauth_signature_method="HMAC-SHA1", oauth_token="#########-******************", oauth_timestamp="1325192643", oauth_nonce="***********", oauth_version="1.0", oauth_signature="****************%3D"
[x-auth-service-provider] => https://api.twitter.com/1/account/verify_credentials.json
[content-type] => multipart/form-data
)
Run Code Online (Sandbox Code Playgroud)
我确保verify_credentials签名使用GET,我看不到任何其他问题.
我究竟做错了什么?
谢谢 :)
编辑:这是我的源代码.
$venue = $this->Venue->findById($venueId);
$twitterData = json_decode($venue['Venue']['twitter_data']);
$token = $twitterData->token;
$secret = $twitterData->secret;
$this->Twitter->loginTwitterUser($token, $secret);
require_once(WWW_ROOT.'twitpic/TwitPic.php');
$twitpic = new TwitPic('**********', '*******', '*********', $token, $secret);
$result['result'] = $twitpic->upload(array('media'=> '/home/todays/public_html/tsm/app/webroot/files/uploads/LOGOA7V1_10.png', 'message'=> 'test'));
Run Code Online (Sandbox Code Playgroud)
我确信令牌,秘密和应用凭据是正确的,因为它们在我的Twitter API中工作没有任何问题.我还仔细检查了Twitpic API密钥.
我正在应用程序的 HTTP 标头中添加Feature-Policy。它运行良好,但我在 Chrome 上有这种消息:
Error with Feature-Policy header: Unrecognized feature: 'document-domain'.
Run Code Online (Sandbox Code Playgroud)
Chrome 无法识别此功能,但 Firefox 可以识别此功能。此消息会导致应用程序测试套件出现问题。
我检查了我们可以与 Chrome 一起使用的开关列表,但没有找到合适的开关。我知道根据所使用的浏览器可能会更改标题,但这很麻烦。理想的做法是在标题中添加一些内容。
最好的解决方案是什么?
我有一个反应 js 应用程序。我想在从应用程序返回的每个响应中添加一些 http 标头。您能否建议如何实现这一点!
注意:我不想在请求中调用任何带有标头的 api。我希望我的反应应用程序在响应中使用一些自定义标头进行响应
我正在尝试向我的请求添加自定义标头,但必须在界面中对其进行修改/实现。
默认Request接口引用IncomingHttpHeaders. 所以我试图用我自己的自定义令牌标头扩展这个接口。
import { IncomingHttpHeaders } from 'http';
declare module 'express-serve-static-core' {
interface IncomingHttpHeaders {
"XYZ-Token"?: string
}
}
Run Code Online (Sandbox Code Playgroud)
我已更新我的.tsconfig文件以读取该./types文件夹。我的文件名是index.d.ts
如果我不使用自定义标头,我可以成功编译代码,但是当我尝试在代码中引用令牌标头时,我收到以下编译错误:
错误
error TS2538: Type 'string[]' cannot be used as an index type.
req.headers['XYZ-Token']
Run Code Online (Sandbox Code Playgroud)
如果我使用原始界面的任何值,一切正常。
例子:
req.headers['user-agent']
Run Code Online (Sandbox Code Playgroud)
附加信息:我正在使用 NestJS,它在底层使用 Fastify/Express。我可以确认正在使用的请求接口来自 Express。Fastify 向后兼容所有 Express 模块。主要使用 Fastify 因为它更快。
我正在为我的项目使用 reactjs,但我有一个问题,在 config.js 文件中,我在其中设置了全局 axios 配置,我正在为 axios 请求设置默认标头,但是当我发出 axios 请求时,它不会在请求中发送这些标头.
配置文件
import axios from 'axios';
const instance = axios.create({
baseURL: 'URL/api'
});
export const setAuthToken = (token) => {
if (token) {
// Apply to every request
instance.defaults.headers.common['Authorization'] = 'Bearer ' + token;
} else {
// Delete auth header
delete instance.defaults.headers.common['Authorization'];
}
};
export default instance;
Run Code Online (Sandbox Code Playgroud)
登录.js
import axios from '../../../config';
import { setAuthToken } from '../../../config';
axios
.post('/auth/signin', {
username: email,
password: password
})
.then((res) => {
setCurrentUser(res.data); …Run Code Online (Sandbox Code Playgroud)