HttpRequest::getHeaders() a content-type
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Honza Kuchař
- Člen | 1662
Jak jsem tak zjistil, tak algoritmus používaný v metodě getHeaders není funkční úplně na 100%. :( Pokud Nette neběží pod Apache, tak není možné přes HttpRequest zjistit opravdu všechny hlavičky. Nette totiž předpokládá HTTP_NAZEV_HLAVICKY. :( Asi bude potřeba sepsat hlavičky, které bude potřeba do funkce getHeaders přidat ručně.
Příklad metoda s PHP spuštěného jako CGI (nejspíš):
Hlavičky
Array
(
[accept] => "text/*"
[cache-control] => no-cache
[connection] => Keep-Alive
[host] => ciki.gamepub.sk
[user-agent] => Shockwave Flash
)
$_SERVER:
Array
(
[CONTENT_LENGTH] => 1038
[CONTENT_TYPE] => multipart/form-data; boundary=----------KM7ae0ae0Ij5gL6KM7cH2Ef1Ef1KM7
[DOCUMENT_ROOT] => /sroot/www
[GATEWAY_INTERFACE] => CGI/1.1
[HTTP_ACCEPT] => text/*
[HTTP_CACHE_CONTROL] => no-cache
[HTTP_CONNECTION] => Keep-Alive
[HTTP_HOST] => ciki.gamepub.sk
[HTTP_USER_AGENT] => Shockwave Flash
[PATH] => /bin:/usr/bin
[QUERY_STRING] => do=form-submit
[REDIRECT_STATUS] => 200
[REMOTE_ADDR] => 77.240.187.175
[REMOTE_PORT] => 54195
[REQUEST_METHOD] => POST
[REQUEST_URI] => /multipleFileUpload/document_root/?do=form-submit
[SCRIPT_FILENAME] => /sroot/www/gamepub.sk/ciki/multipleFileUpload/document_root/index.php
[SCRIPT_NAME] => /multipleFileUpload/document_root/index.php
[SCRIPT_URI] => http://ciki.gamepub.sk/multipleFileUpload/document_root/
[SCRIPT_URL] => /multipleFileUpload/document_root/
[SERVER_ADDR] => 217.73.17.146
[SERVER_ADMIN] => server@gamepub.sk
[SERVER_NAME] => ciki.gamepub.sk
[SERVER_PORT] => 80
[SERVER_PROTOCOL] => HTTP/1.1
[SERVER_SIGNATURE] => <address>Apache Server at ciki.gamepub.sk Port 80</address>
[SERVER_SOFTWARE] => Apache
[UNIQUE_ID] => S37STX8AAAEAAFGxtIsAAAAJ
[PHP_SELF] => /multipleFileUpload/document_root/index.php
[REQUEST_TIME] => 1266602573
[argv] => Array
(
[0] => do=form-submit
)
[argc] => 1
)
PHP spuštěného pod Apache (localhost):
Hlavičky:
Array
(
[accept] => text/*
[content-type] => multipart/form-data; boundary=----------Ef1GI3ae0Ij5cH2GI3gL6KM7gL6ei4
[user-agent] => Shockwave Flash
[host] => localhost
[content-length] => 3516
[connection] => Keep-Alive
[cache-control] => no-cache
)
$_SERVER:
Array
(
[MIBDIRS] => C:/xampp/php/extras/mibs
[MYSQL_HOME] => C:\xampp\mysql\bin
[OPENSSL_CONF] => C:/xampp/apache/bin/openssl.cnf
[PHP_PEAR_SYSCONF_DIR] => C:\xampp\php
[PHPRC] => C:\xampp\php
[TMP] => C:\xampp\tmp
[HTTP_ACCEPT] => text/*
[CONTENT_TYPE] => multipart/form-data; boundary=----------Ij5gL6Ef1cH2ae0cH2GI3ei4KM7Ef1
[HTTP_USER_AGENT] => Shockwave Flash
[HTTP_HOST] => localhost
[CONTENT_LENGTH] => 1050
[HTTP_CONNECTION] => Keep-Alive
[HTTP_CACHE_CONTROL] => no-cache
[PATH] => C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files (x86)\CollabNet\Subversion Client;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;c:\xampp\php;C:\Program Files (x86)\QuickTime\QTSystem\;
[SystemRoot] => C:\Windows
[COMSPEC] => C:\Windows\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
[WINDIR] => C:\Windows
[SERVER_SIGNATURE] => <address>Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0 Server at localhost Port 80</address>
[SERVER_SOFTWARE] => Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0
[SERVER_NAME] => localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] => 80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] => D:/www
[SERVER_ADMIN] => postmaster@localhost
[SCRIPT_FILENAME] => D:/www/55_Libraries/MultipleFileUpload-svn/document_root/index.php
[REMOTE_PORT] => 54073
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => POST
[QUERY_STRING] => do=form-submit
[REQUEST_URI] => /55_Libraries/MultipleFileUpload-svn/document_root/?do=form-submit
[SCRIPT_NAME] => /55_Libraries/MultipleFileUpload-svn/document_root/index.php
[PHP_SELF] => /55_Libraries/MultipleFileUpload-svn/document_root/index.php
[REQUEST_TIME] => 1266602406
[argv] => Array
(
[0] => do=form-submit
)
[argc] => 1
)
Z tohoto příkladu jde vidět, že bude potřeba přepisovat kromě
hlaviček prefixovaných HTTP_
, tak i ty s
CONTENT_
.
Editoval honzakuchar (19. 2. 2010 19:06)