Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

drupal 6 - PHP: Get http status code that own script just sent out via shutdown function -


i have shutdown function checks see if redirect issued. headers_list() can headers sent , see location header. question how figure out http_response_code used in header() function. headers list doesn't have response code.

example code play around with. don't use redirects in example code, otherwise loop. main thing detect 301 vs other kind of redirect. inside drupal (via drupal_goto using hook_exit); example code below shows issue. have no way of knowing status number passed browser via header().

<?php register_shutdown_function('test');  if (mt_rand(0, 1)) {   header('x-test: junk 1', true, 201); } else {   header('x-test: junk 0', true, 202); }  exit();   function test() {   if ($location = test_headers_contain('x-test: ')) {     // check status code sent out     echo $location . '<br>';     $list = headers_list();     $txt = str_replace('    ', '&nbsp;&nbsp;&nbsp;&nbsp;', nl2br(htmlentities(print_r($list, true))));     echo $txt;   } }  function test_headers_contain($text) {   if (function_exists('headers_list')) {     $list = headers_list();     if (empty($list)) {       return false;     }     foreach ($list $header) {       $info = stristr($header, $text);       if ($info !== false) {         return $info;       }     }   }   return false; } ?> 

this code outputs this

x-test: junk 1 array (     [0] => x-powered-by: php/5.2.10     [1] => x-test: junk 1 ) 

revision 302033 added function http_response_code in response sort of issue describe, i'm not when included in release. it's not in 5.3.4. if have access, build patched version of php function added. if not, request of whoever on host have access.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -