🌐 AI搜索 & 代理 主页
Skip to content

Commit 15cdd7a

Browse files
Ajax: unit test for cors
1 parent 401ff0a commit 15cdd7a

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

test/data/mock.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ protected function script( $req ) {
6161

6262
if ( !empty( $req->query['callback'] ) ) {
6363
$headers = array_combine(
64-
array_map( 'strtolower', array_keys( $req->headers ) ),
64+
array_map( 'strtolower', array_keys( $req->headers ) ),
6565
array_values( $req->headers )
6666
);
6767

68-
echo "{$req->query['callback']}(" . json_encode( $req->headers ) . ")";
68+
echo "{$req->query['callback']}(" . json_encode( $req->headers ) . ")";
6969
} else {
7070
echo 'QUnit.assert.ok( true, "mock executed" );';
7171
}
@@ -249,17 +249,6 @@ protected function errorWithScript( $req ) {
249249
}
250250
}
251251

252-
protected function cors( $req ) {
253-
if ( isset( $req->headers['ORIGIN'] ) ) {
254-
$origin = $req->headers['ORIGIN'];
255-
header( "Access-Control-Allow-Methods: GET" );
256-
header( "Access-Control-Allow-Origin: " . $origin );
257-
echo 'corsCallback( true )';
258-
} else {
259-
echo 'corsCallback( false )';
260-
}
261-
}
262-
263252
public function __construct() {
264253
$this->cspFile = __DIR__ . '/support/csp.log';
265254
}

0 commit comments

Comments
 (0)