私はサーバーアプリケーションにサーバーを持っています。サーバー1のPHPスクリプト(ドメイン1)は、ページにカスタムヘッダーを設定します(承認:Bearer 123456789)。サーバー2のスクリプトでは、ドメイン2はget_headers()を使用してヘッダーを読み取ります。Joomlaがカスタムヘッダーを送信しない
ファイルがネイティブに配信されると、すべて正常に動作します。しかし、サーバ1のスクリプトがJoomlaモジュールに含まれている場合、get_headers()はカスタムヘッダを取得しません。
いずれの場合でも、開発者ツールはカスタムヘッダーを表示するだけでなく、get_headers()が返すヘッダーとは異なるヘッダーも表示します。
以下のコードはJoomlaがロードされている場合にJFactoryを使用してヘッダーを設定しますが、header()を使用した場合と同じ結果になります。 Joomlaはカスタムヘッダーを渡していません。
私はそれを取得しません。誰でもここで何が起こっているか考えている? SEFやhtaccessの問題ではありません。
<?php
// Server 1
if(!class_exists("JFactory")){ // no Joomla
header('Authorization: Bearer 123456789');
} else { // Joomla framework loaded
$app = JFactory::getApplication();
$app->setHeader('Authorization: ', 'Bearer 123456789');
$app->sendHeaders();
}
サーバ2上のコード:get_headersから
<?php
// Server 2
$headers = get_headers("http://server1.com/");
foreach($headers as $header) {
echo $header ."<br/>";
}
出力()ネイティブ配信:get_headers(から
HTTP/1.1 200 OK Date: Thu, 19 Jan 2017 12:44:35 GMT Server: Apache Authorization: Bearer 123456789 Content-Length: 0 Connection: close Content-Type: text/html
出力)のJoomlaによってサービスとき:
HTTP/1.1 200 OK Date: Thu, 19 Jan 2017 12:45:49 GMT Server: Apache Set-Cookie: 3c460b3da9ecb202e794816b4144c6ff=ja7mn4b4njov98lsv76kk8pvu2; path=/; HttpOnly Vary: Accept-Encoding Content-Length: 1264 Connection: close Content-Type: text/html
ネイティブヘッダ:開発者用ツールで表示
Authorization: Bearer 123456789 Date: Thu, 19 Jan 2017 13:07:32 GMT Server: Apache Connection: Keep-Alive Keep-Alive: timeout=5, max=100 Content-Length: 0 Content-Type: text/html 200 OK
Joomlaのヘッダ:
Pragma: no-cache Date: Thu, 19 Jan 2017 12:19:24 GMT Last-Modified: Thu, 19 Jan 2017 12:19:25 GMT Server: Apache Authorization: : Bearer 123456789 Vary: Accept-Encoding Content-Type: text/html; charset=utf-8 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Connection: Keep-Alive Keep-Alive: timeout=5, max=100 Content-Length: 76888 Expires: Wed, 17 Aug 2005 00:00:00 GMT