send_origin_headers() - WordPress 函数参考中文文档

返回介绍

send_origin_headers()

发布于 2017-09-11 字数1760 浏览 1126 评论 0

send_origin_headers()

Send Access-Control-Allow-Origin and 相关函数 headers if the current request is from an allowed origin.


描述

If the request is an OPTIONS request, the script exits with either access control headers sent, or a 403 response if the origin is not allowed. For other request methods, you will receive a return value.


返回值

(string|false) Returns the origin URL if headers are sent. Returns false if headers are not sent.


源代码

File: wp-includes/http.php

function send_origin_headers() {
	$origin = get_http_origin();

	if ( is_allowed_http_origin( $origin ) ) {
		@header( 'Access-Control-Allow-Origin: ' .  $origin );
		@header( 'Access-Control-Allow-Credentials: true' );
		if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] )
			exit;
		return $origin;
	}

	if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
		status_header( 403 );
		exit;
	}

	return false;
}

更新日志

Version 描述
3.4.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    status_header()
  • wp-includes/http.php:
    is_allowed_http_origin()
  • wp-includes/http.php:
    get_http_origin()

Used By

  • wp-includes/class-wp-customize-manager.php:
    WP_Customize_Manager::setup_theme()

User Contributed Notes

上一篇:send_nosniff_header()

下一篇:separate_comments()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!