HttpURLConnection类学习笔记

 1、java.lang.Object
  java.net.URLConnection
      java.net.HttpURLConnection
2、public abstract class HttpURLConnection extends URLConnection

支持 HTTP 特定功能的 URLConnection。

每个 HttpURLConnection 实例都可用于生成单个请求,但是其他实例可以透明地共享连接到 HTTP 服务器的基础网络。请求后在 HttpURLConnection 的 InputStream 或 OutputStream 上调用 close() 方法可以释放与此实例关联的网络资源,但对共享的持久连接没有任何影响。如果在调用 disconnect() 时持久连接空闲,则可能关闭基础套接字。

3、字段

protected  int chunkLength
          使用存储块编码流模式进行输出时的存储块长度。
protected  int fixedContentLength
          使用固定长度流模式时的固定内容长度。
static int HTTP_ACCEPTED
          HTTP 状态码 202:Accepted。
static int HTTP_BAD_GATEWAY
          HTTP 状态码 502:Bad Gateway。
static int HTTP_BAD_METHOD
          HTTP 状态码 405:Method Not Allowed。
static int HTTP_BAD_REQUEST
          HTTP 状态码 400:Bad Request。
static int HTTP_CLIENT_TIMEOUT
          HTTP 状态码 408:Request Time-Out。
static int HTTP_CONFLICT
          HTTP 状态码 409:Conflict。
static int HTTP_CREATED
          HTTP 状态码 201:Created。
static int HTTP_ENTITY_TOO_LARGE
          HTTP 状态码 413:Request Entity Too Large。
static int HTTP_FORBIDDEN
          HTTP 状态码 403:Forbidden。
static int HTTP_GATEWAY_TIMEOUT
          HTTP 状态码 504:Gateway Timeout。
static int HTTP_GONE
          HTTP 状态码 410:Gone。
static int HTTP_INTERNAL_ERROR
          HTTP 状态码 500:Internal Server Error。
static int HTTP_LENGTH_REQUIRED
          HTTP 状态码 411:Length Required。
static int HTTP_MOVED_PERM
          HTTP 状态码 301:Moved Permanently。
static int HTTP_MOVED_TEMP
          HTTP 状态码 302:Temporary Redirect。
static int HTTP_MULT_CHOICE
          HTTP 状态码 300:Multiple Choices。
static int HTTP_NO_CONTENT
          HTTP 状态码 204:No Content。
static int HTTP_NOT_ACCEPTABLE
          HTTP 状态码 406:Not Acceptable。
static int HTTP_NOT_AUTHORITATIVE
          HTTP 状态码 203:Non-Authoritative Information。
static int HTTP_NOT_FOUND
          HTTP 状态码 404:Not Found。
static int HTTP_NOT_IMPLEMENTED
          HTTP 状态码 501:Not Implemented。
static int HTTP_NOT_MODIFIED
          HTTP 状态码 304:Not Modified。
static int HTTP_OK
          HTTP 状态码 200:OK。
static int HTTP_PARTIAL
          HTTP 状态码 206:Partial Content。
static int HTTP_PAYMENT_REQUIRED
          HTTP 状态码 402:Payment Required。
static int HTTP_PRECON_FAILED
          HTTP 状态码 412:Precondition Failed。
static int HTTP_PROXY_AUTH
          HTTP 状态码 407:Proxy Authentication Required。
static int HTTP_REQ_TOO_LONG
          HTTP 状态码 414:Request-URI Too Large。
static int HTTP_RESET
          HTTP 状态码 205:Reset Content。
static int HTTP_SEE_OTHER
          HTTP 状态码 303:See Other。
static int HTTP_SERVER_ERROR
          已过时。 放错了位置,它不应该存在。
static int HTTP_UNAUTHORIZED
          HTTP 状态码 401:Unauthorized。
static int HTTP_UNAVAILABLE
          HTTP 状态码 503:Service Unavailable。
static int HTTP_UNSUPPORTED_TYPE
          HTTP 状态码 415:Unsupported Media Type。
static int HTTP_USE_PROXY
          HTTP 状态码 305:Use Proxy。
static int HTTP_VERSION
          HTTP 状态码 505:HTTP Version Not Supported。
protected  boolean instanceFollowRedirects
          如果为 true,则协议自动执行重定向。
protected  String method
          HTTP 方法(GET、POST、PUT 等)。
protected  int responseCode
          表示三位字数的 HTTP 状态码 (Status-Code) 的 int
protected  String responseMessage
          HTTP 响应消息。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章