您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

129 行
3.5 KiB

  1. <?php
  2. /**
  3. * *************************************************************************
  4. *
  5. * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
  6. *
  7. * ************************************************************************
  8. */
  9. /**
  10. *
  11. * @file debug.php
  12. * @encoding UTF-8
  13. *
  14. *
  15. * @date 2014年12月25日
  16. *
  17. */
  18. if(!defined('PUSH_SDK_HOME')){
  19. define('PUSH_SDK_HOME', dirname(dirname(__FILE__)));
  20. }
  21. include_once PUSH_SDK_HOME.'/lib/PushSimpleLog.php';
  22. /**
  23. * 取得根据http状态码取得对应的默认状态消息
  24. * @param unknown $code
  25. */
  26. function send_http_status($code) {
  27. static $_status = array (
  28. // Informational 1xx
  29. 100 => 'Continue',
  30. 101 => 'Switching Protocols',
  31. // Success 2xx
  32. 200 => 'OK',
  33. 201 => 'Created',
  34. 202 => 'Accepted',
  35. 203 => 'Non-Authoritative Information',
  36. 204 => 'No Content',
  37. 205 => 'Reset Content',
  38. 206 => 'Partial Content',
  39. // Redirection 3xx
  40. 300 => 'Multiple Choices',
  41. 301 => 'Moved Permanently',
  42. 302 => 'Moved Temporarily ', // 1.1
  43. 303 => 'See Other',
  44. 304 => 'Not Modified',
  45. 305 => 'Use Proxy',
  46. // 306 is deprecated but reserved
  47. 307 => 'Temporary Redirect',
  48. // Client Error 4xx
  49. 400 => 'Bad Request',
  50. 401 => 'Unauthorized',
  51. 402 => 'Payment Required',
  52. 403 => 'Forbidden',
  53. 404 => 'Not Found',
  54. 405 => 'Method Not Allowed',
  55. 406 => 'Not Acceptable',
  56. 407 => 'Proxy Authentication Required',
  57. 408 => 'Request Timeout',
  58. 409 => 'Conflict',
  59. 410 => 'Gone',
  60. 411 => 'Length Required',
  61. 412 => 'Precondition Failed',
  62. 413 => 'Request Entity Too Large',
  63. 414 => 'Request-URI Too Long',
  64. 415 => 'Unsupported Media Type',
  65. 416 => 'Requested Range Not Satisfiable',
  66. 417 => 'Expectation Failed',
  67. // Server Error 5xx
  68. 500 => 'Internal Server Error',
  69. 501 => 'Not Implemented',
  70. 502 => 'Bad Gateway',
  71. 503 => 'Service Unavailable',
  72. 504 => 'Gateway Timeout',
  73. 505 => 'HTTP Version Not Supported',
  74. 509 => 'Bandwidth Limit Exceeded',
  75. );
  76. if (array_key_exists($code, $_status)) {
  77. header('HTTP/1.1 ' . $code . ' ' . $_status [$code]);
  78. }
  79. }
  80. $log = new PushSimpleLog('stdout',0);
  81. if(array_key_exists('q', $_REQUEST)){
  82. $log->log(print_r($_REQUEST['q'],true));
  83. switch($_REQUEST['q']){
  84. case "404_1":
  85. send_http_status(404);
  86. echo '{"request_id":100, "error_code":10000 , "error_msg":"what is that??"}';
  87. break;
  88. case "404_2":
  89. send_http_status(404);
  90. echo 'what is this??';
  91. break;
  92. case "200_1":
  93. send_http_status(200);
  94. echo '{"request_id":100, "response_params":[1,2,3,4]}';
  95. break;
  96. case "200_2":
  97. send_http_status(200);
  98. echo 'what is this??';
  99. case "200_3":
  100. send_http_status(200);
  101. echo '{"request_id":100, "error_code":4567}';
  102. break;
  103. case 'checkSign' :
  104. send_http_status(200);
  105. $rs = array(
  106. 'request_id' => 100,
  107. 'response_params' => $_REQUEST,
  108. );
  109. echo json_encode($rs);
  110. break;
  111. default:
  112. send_http_status(204);
  113. }
  114. }else{
  115. $log->log(print_r($_REQUEST,true));
  116. echo json_encode($_REQUEST);
  117. }