function test_mixed_case_key_doesnt_get_conflated() { $g = new k_adapter_SafeGlobalsAccess(new k_charset_Latin1CharsetStrategy(), true); $_GET = array('foo' => "42", 'Foo' => "1337"); $this->assertEqual($g->query(), array('foo' => "42", 'Foo' => "1337")); }
/** * @param string * @param string * @param k_IdentityLoader * @param k_LanguageLoader * @param k_TranslatorLoader * @param k_adapter_GlobalsAccess * @param k_adapter_CookieAccess * @param k_adapter_SessionAccess */ function __construct($href_base = null, $request_uri = null, k_IdentityLoader $identity_loader = null, k_LanguageLoader $language_loader = null, k_TranslatorLoader $translator_loader = null, k_adapter_GlobalsAccess $superglobals = null, k_adapter_CookieAccess $cookie_access = null, k_adapter_SessionAccess $session_access = null, k_adapter_UploadedFileAccess $file_access = null) { if (preg_match('~/$~', $href_base)) { throw new Exception("href_base may _not_ have trailing slash"); } if (preg_match('~^\\w+://\\w+\\.~', $href_base)) { throw new Exception("href_base may _not_ include hostname"); } if (!$superglobals) { $superglobals = new k_adapter_SafeGlobalsAccess(new k_charset_Utf8CharsetStrategy()); } if (!$file_access) { $file_access = new k_adapter_DefaultUploadedFileAccess(); } $this->query = $superglobals->query(); $this->body = $superglobals->body(); $this->rawHttpRequestBody = $superglobals->rawHttpRequestBody(); $this->server = $superglobals->server(); $this->files = array(); foreach ($superglobals->files() as $key => $file_info) { if (array_key_exists('name', $file_info)) { $this->files[$key] = new k_adapter_UploadedFile($file_info, $key, $file_access); } else { $this->files[$key] = array(); foreach ($file_info as $file_info_struct) { $this->files[$key][] = new k_adapter_UploadedFile($file_info_struct, $key, $file_access); } } } $this->headers = $this->lowerKeys($superglobals->headers()); $this->cookie_access = $cookie_access ? $cookie_access : new k_adapter_DefaultCookieAccess($this->server['SERVER_NAME'], $superglobals->cookie()); $this->session_access = $session_access ? $session_access : new k_adapter_DefaultSessionAccess($this->cookie_access); $this->identity_loader = $identity_loader ? $identity_loader : new k_DefaultIdentityLoader(); $this->language_loader = $language_loader; $this->translator_loader = $translator_loader; $this->href_base = $href_base === null ? preg_replace('~(.*)/.*~', '$1', $this->server['SCRIPT_NAME']) : $href_base; $this->request_uri = $request_uri === null ? $this->server['REQUEST_URI'] : $request_uri; $this->subspace = preg_replace('~^' . preg_quote($this->href_base, '~') . '~', '', preg_replace('~([?]{1}.*)$~', '', $this->request_uri)); $this->content_type_negotiator = new k_ContentTypeNegotiator($this->header('accept')); }