phpDocumentor http
response
[ class tree: http ] [ index: http ] [ all elements ]

Class: WindHttpResponse

Source Location: /http/response/WindHttpResponse.php

Class WindHttpResponse

Class Overview

Implements interfaces:

response实现类

相应状态码信息描述: 1xx:信息,请求收到,继续处理 2xx:成功,行为被成功地接受、理解和采纳 3xx:重定向,为了完成请求,必须进一步执行的动作 4xx:客户端错误,请求包含语法错误或者请求无法实现 5xx:服务器错误,服务器不能实现一种明显无效的请求

Located in /http/response/WindHttpResponse.php [line 20]



		
				Author(s):
		
		
		
Information Tags:
Version:  $Id: WindHttpResponse.php 3253 2011-12-19 10:10:03Z yishuo $
Copyright:  ©2003-2103 phpwind.com
License:  http://www.windframework.com

Methods

[ Top ]
Constant Summary
W_ACCEPTED   Status code (202)
W_BAD_GATEWAY   Status code (502)
W_BAD_REQUEST   Status code (400)
W_CONFLICT   Status code (409)
W_CONTINUE   Status code (100)
W_CREATED   Status code (201)
W_EXPECTATION_FAILED   Status code (417)
W_FORBIDDEN   Status code (403)
W_FOUND   Status code (302)
W_GATEWAY_TIMEOUT   Status code (504)
W_GONE   Status code (410)
W_HTTP_VERSION_NOT_SUPPORTED   Status code (505)
W_INTERNAL_SERVER_ERROR   Status code (500)
W_LENGTH_REQUIRED   Status code (411)
W_METHOD_NOT_ALLOWED   Status code (405)
W_MOVED_PERMANENTLY   Status code (301)
W_MOVED_TEMPORARILY   Status code (302)
W_MULTIPLE_CHOICES   Status code (300)
W_NON_AUTHORITATIVE_INFORMATION   Status code (203)
W_NOT_ACCEPTABLE   Status code (406)
W_NOT_FOUND   Status code (404)
W_NOT_IMPLEMENTED   Status code (501)
W_NOT_MODIFIED   Status code (304)
W_NO_CONTENT   Status code (204)
W_OK   Status code (200)
W_PARTIAL_CONTENT   Status code (206)
W_PAYMENT_REQUIRED   Status code (402)
W_PRECONDITION_FAILED   Status code (412)
W_PROXY_AUTHENTICATION_REQUIRED   Status code (407)
W_REQUESTED_RANGE_NOT_SATISFIABLE   Status code (416)
W_REQUEST_ENTITY_TOO_LARGE   Status code (413)
W_REQUEST_TIMEOUT   Status code (408)
W_REQUEST_URI_TOO_LONG   Status code (414)
W_RESET_CONTENT   Status code (205)
W_SEE_OTHER   Status code (303)
W_SERVICE_UNAVAILABLE   Status code (503)
W_SWITCHING_PROTOCOLS   Status code (101) indicating the server is switching protocols according to Upgrade header.
W_TEMPORARY_REDIRECT   Status code (307)
W_UNAUTHORIZED   Status code (401)
W_UNSUPPORTED_MEDIA_TYPE   Status code (415)
W_USE_PROXY   Status code (305)

[ Top ]
Method Summary
void   addCookie()   添加cookie信息
void   addHeader()   设置响应头信息,如果已经设置过同名的响应头,该方法将增加一个同名的响应头
void   clearBody()   清理响应体信息
void   clearHeaders()   清除响应头信息
string   codeMap()   状态码映射
mixed   getBody()   获取响应内容
string   getCharset()   获得输出的编码方式
mixed   getData()   获得保存输出数据
array   getHeaders()   获取响应头信息
string   getResponseType()  
boolean   isSendedHeader()   是否已经发送了响应头部
void   sendBody()   发送响应内容
void   sendError()   发送一个错误的响应信息
void   sendHeaders()   发送响应头部信息
void   sendRedirect()   重定向一个响应信息
void   sendResponse()   发送响应信息
void   setBody()   设置响应内容
void   setCharset()   设置输出的编码方式
void   setData()   设置保存输出数据
void   setHeader()   设置响应头信息,如果已经设置过同名的响应头,该方法将用新的设置取代原来的头字段
void   setResponseType()   设置当前请求的返回类型
void   setStatus()   设置响应头状态码

[ Top ]
Methods
addCookie  [line 663]

  void addCookie( Cookie $cookie  )

添加cookie信息

Parameters:
Cookie   $cookie:  添加cookie信息

API Tags:
Access:  public


[ Top ]
addHeader  [line 605]

  void addHeader( string $name, string $value, [int $replace = false]  )

设置响应头信息,如果已经设置过同名的响应头,该方法将增加一个同名的响应头

Parameters:
string   $name:  响应头的名称
string   $value:  响应头的字段取值
int   $replace:  响应头信息的replace项值

API Tags:
Access:  public


[ Top ]
clearBody  [line 794]

  void clearBody( )

清理响应体信息


API Tags:
Access:  public


[ Top ]
clearHeaders  [line 803]

  void clearHeaders( )

清除响应头信息


API Tags:
Access:  public


[ Top ]
codeMap  [line 512]

  string codeMap( int $code  )

状态码映射

Parameters:
int   $code:  状态码

API Tags:
Access:  public


[ Top ]
getBody  [line 750]

  mixed getBody( [string $name = false]  )

获取响应内容

Parameters:
string   $name:  内容的名称,默认为false:
  • false: 字符串方式返回所有内容
  • true: 返回响应内容的片段数组
  • string类型: 响应内容中该片段的内容
  • other: 返回null

API Tags:
Access:  public


[ Top ]
getCharset  [line 616]

  string getCharset( )

获得输出的编码方式


API Tags:
Access:  public


[ Top ]
getData  [line 826]

  mixed getData( string $var=..  )

获得保存输出数据

Parameters:
string   $var=..: 

API Tags:
Access:  public


[ Top ]
getHeaders  [line 785]

  array getHeaders( )

获取响应头信息


API Tags:
Access:  public


[ Top ]
getResponseType  [line 562]

  string getResponseType( )


API Tags:
Return:  返回当前请求的返回类型
Access:  public


[ Top ]
isSendedHeader  [line 772]

  boolean isSendedHeader( [boolean $throw = false]  )

是否已经发送了响应头部

Parameters:
boolean   $throw:  是否抛出错误,默认为false:
  • true: 如果已经发送了头部则抛出异常信息
  • false: 无论如何都不抛出异常信息

API Tags:
Return:  已经发送头部信息则返回true否则返回false
Access:  public


[ Top ]
sendBody  [line 731]

  void sendBody( )

发送响应内容


API Tags:
Access:  public


[ Top ]
sendError  [line 674]

  void sendError( [int $status = self::W_NOT_FOUND], [string $message = '']  )

发送一个错误的响应信息

Parameters:
int   $status:  错误码,默认为404
string   $message:  错误信息,默认为空

API Tags:
Access:  public


[ Top ]
sendHeaders  [line 715]

  void sendHeaders( )

发送响应头部信息


API Tags:
Access:  public


[ Top ]
sendRedirect  [line 688]

  void sendRedirect( string $location, [int $status = 302]  )

重定向一个响应信息

Parameters:
string   $location:  重定向的地址
int   $status:  状态码,默认为302

API Tags:
Access:  public


[ Top ]
sendResponse  [line 705]

  void sendResponse( )

发送响应信息

依次发送响应头和响应内容


API Tags:
Access:  public


[ Top ]
setBody  [line 650]

  void setBody( string $content, [string $name = null]  )

设置响应内容

Parameters:
string   $content:  响应内容信息
string   $name:  相应内容片段名字,默认为null

API Tags:
Access:  public


[ Top ]
setCharset  [line 626]

  void setCharset( string $_charset  )

设置输出的编码方式

Parameters:
string   $_charset:  编码方式

API Tags:
Access:  public


[ Top ]
setData  [line 843]

  void setData( mixed $data, [string $key = ''], [ $merge = false]  )

设置保存输出数据

Parameters:
mixed   $data:  待保存的输出数据
string   $key:  输出数据的key名称,默认为空
   $merge: 

API Tags:
Access:  public


[ Top ]
setHeader  [line 583]

  void setHeader( string $name, string $value, [int $replace = false]  )

设置响应头信息,如果已经设置过同名的响应头,该方法将用新的设置取代原来的头字段

Parameters:
string   $name:  响应头的名称
string   $value:  响应头的字段取值
int   $replace:  响应头信息的replace项值

API Tags:
Access:  public


[ Top ]
setResponseType  [line 571]

  void setResponseType( string $responseType  )

设置当前请求的返回类型

Parameters:
string   $responseType: 

API Tags:
Access:  public


[ Top ]
setStatus  [line 637]

  void setStatus( int $status, [string $message = '']  )

设置响应头状态码

Parameters:
int   $status:  响应状态码
string   $message:  相应状态信息,默认为空字串

API Tags:
Access:  public


[ Top ]
Constants
W_ACCEPTED = 202 [line 121]

Status code (202)

Status code (202) indicating that a request was accepted for processing, but was not completed.


[ Top ]
W_BAD_GATEWAY = 502 [line 472]

Status code (502)

Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway.


[ Top ]
W_BAD_REQUEST = 400 [line 263]

Status code (400)

Status code (400) indicating the request sent by the client was syntactically incorrect.


[ Top ]
W_CONFLICT = 409 [line 356]

Status code (409)

Status code (409) indicating that the request could not be completed due to a conflict with the current state of the resource.


[ Top ]
W_CONTINUE = 100 [line 86]

Status code (100)

Server status codes; see RFC 2068. Status code (100) indicating the client can continue.


[ Top ]
W_CREATED = 201 [line 111]

Status code (201)

Status code (201) indicating the request succeeded and created a new resource on the server.


[ Top ]
W_EXPECTATION_FAILED = 417 [line 441]

Status code (417)

Status code (417) indicating that the server could not meet the expectation given in the Expect request header.


[ Top ]
W_FORBIDDEN = 403 [line 292]

Status code (403)

Status code (403) indicating the server understood the request but refused to fulfill it.


[ Top ]
W_FOUND = 302 [line 210]

Status code (302)

Status code (302) indicating that the resource reside temporarily under a different URI. Since the redirection might be altered on occasion, the client should continue to use the Request-URI for future requests.(HTTP/1.1) To represent the status code (302), it is recommended to use this variable.


[ Top ]
W_GATEWAY_TIMEOUT = 504 [line 493]

Status code (504)

Status code (504) indicating that the server did not receive a timely response from the upstream server while acting as a gateway or proxy.


[ Top ]
W_GONE = 410 [line 367]

Status code (410)

Status code (410) indicating that the resource is no longer available at the server and no forwarding address is known. This condition <em>SHOULD</em> be considered permanent.


[ Top ]
W_HTTP_VERSION_NOT_SUPPORTED = 505 [line 504]

Status code (505)

Status code (505) indicating that the server does not support or refuses to support the HTTP protocol version that was used in the request message.


[ Top ]
W_INTERNAL_SERVER_ERROR = 500 [line 451]

Status code (500)

Status code (500) indicating an error inside the HTTP server which prevented it from fulfilling the request.


[ Top ]
W_LENGTH_REQUIRED = 411 [line 377]

Status code (411)

Status code (411) indicating that the request cannot be handled without a defined

  1. <em>Content-Length</em>
.


[ Top ]
W_METHOD_NOT_ALLOWED = 405 [line 313]

Status code (405)

Status code (405) indicating that the method specified in the

  1. <em>Request-Line</em>
is not allowed for the resource identified by the
  1. <em>Request-URI</em>
.


[ Top ]
W_MOVED_PERMANENTLY = 301 [line 183]

Status code (301)

Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.


[ Top ]
W_MOVED_TEMPORARILY = 302 [line 197]

Status code (302)

Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.

This definition is being retained for backwards compatibility. W_FOUND is now the preferred definition.


[ Top ]
W_MULTIPLE_CHOICES = 300 [line 172]

Status code (300)

Status code (300) indicating that the requested resource corresponds to any one of a set of representations, each with its own specific location.


[ Top ]
W_NON_AUTHORITATIVE_INFORMATION = 203 [line 131]

Status code (203)

Status code (203) indicating that the meta information presented by the client did not originate from the server.


[ Top ]
W_NOT_ACCEPTABLE = 406 [line 325]

Status code (406)

Status code (406) indicating that the resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.


[ Top ]
W_NOT_FOUND = 404 [line 302]

Status code (404)

Status code (404) indicating that the requested resource is not available.


[ Top ]
W_NOT_IMPLEMENTED = 501 [line 461]

Status code (501)

Status code (501) indicating the HTTP server does not support the functionality needed to fulfill the request.


[ Top ]
W_NOT_MODIFIED = 304 [line 230]

Status code (304)

Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.


[ Top ]
W_NO_CONTENT = 204 [line 141]

Status code (204)

Status code (204) indicating that the request succeeded but that there was no new information to return.


[ Top ]
W_OK = 200 [line 101]

Status code (200)

Status code (200) indicating the request succeeded normally.


[ Top ]
W_PARTIAL_CONTENT = 206 [line 161]

Status code (206)

Status code (206) indicating that the server has fulfilled the partial GET request for the resource.


[ Top ]
W_PAYMENT_REQUIRED = 402 [line 282]

Status code (402)

Status code (402) reserved for future use.


[ Top ]
W_PRECONDITION_FAILED = 412 [line 388]

Status code (412)

Status code (412) indicating that the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.


[ Top ]
W_PROXY_AUTHENTICATION_REQUIRED = 407 [line 335]

Status code (407)

Status code (407) indicating that the client <em>MUST</em> first authenticate itself with the proxy.


[ Top ]
W_REQUESTED_RANGE_NOT_SATISFIABLE = 416 [line 431]

Status code (416)

Status code (416) indicating that the server cannot serve the requested byte range.


[ Top ]
W_REQUEST_ENTITY_TOO_LARGE = 413 [line 399]

Status code (413)

Status code (413) indicating that the server is refusing to process the request because the request entity is larger than the server is willing or able to process.


[ Top ]
W_REQUEST_TIMEOUT = 408 [line 345]

Status code (408)

Status code (408) indicating that the client did not produce a request within the time that the server was prepared to wait.


[ Top ]
W_REQUEST_URI_TOO_LONG = 414 [line 410]

Status code (414)

Status code (414) indicating that the server is refusing to service the request because the

  1. <em>Request-URI</em>
is longer than the server is willing to interpret.


[ Top ]
W_RESET_CONTENT = 205 [line 151]

Status code (205)

Status code (205) indicating that the agent <em>SHOULD</em> reset the document view which caused the request to be sent.


[ Top ]
W_SEE_OTHER = 303 [line 220]

Status code (303)

Status code (303) indicating that the response to the request can be found under a different URI.


[ Top ]
W_SERVICE_UNAVAILABLE = 503 [line 482]

Status code (503)

Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.


[ Top ]
W_SWITCHING_PROTOCOLS = 101 [line 92]

Status code (101) indicating the server is switching protocols according to Upgrade header.


[ Top ]
W_TEMPORARY_REDIRECT = 307 [line 253]

Status code (307)

Status code (307) indicating that the requested resource resides temporarily under a different URI. The temporary URI <em>SHOULD</em> be given by the

  1. <em>Location</em>
field in the response.


[ Top ]
W_UNAUTHORIZED = 401 [line 273]

Status code (401)

Status code (401) indicating that the request requires HTTP authentication.


[ Top ]
W_UNSUPPORTED_MEDIA_TYPE = 415 [line 421]

Status code (415)

Status code (415) indicating that the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.


[ Top ]
W_USE_PROXY = 305 [line 241]

Status code (305)

Status code (305) indicating that the requested resource <em>MUST</em> be accessed through the proxy given by the

  1. <em>Location</em>
field.


[ Top ]

Documentation generated on Fri, 30 Mar 2012 11:43:34 +0800 by phpDocumentor 1.4.4