Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2110899
  • 博文数量: 413
  • 博客积分: 10926
  • 博客等级: 上将
  • 技术积分: 3862
  • 用 户 组: 普通用户
  • 注册时间: 2006-01-09 18:14
文章分类

全部博文(413)

文章存档

2015年(5)

2014年(1)

2013年(5)

2012年(6)

2011年(138)

2010年(85)

2009年(42)

2008年(46)

2007年(26)

2006年(59)

分类: Java

2010-10-12 12:19:31

  1. Docs
    • Sample
    • xxx
  2. NetworkInterface
    Represent a network interface of the local device. The class provides methods to get all information about the available interfaces of the systems, such as hardware address, display name, mtu, etc.
  3. Address
    Related classes/interfaces
    • InetAddress
    • SocketAddress
    • InetSocketAddress
      InetAddress -> InetSocketAddress -> SocketAddress
    • InetAddressUtils

  4. Socket
    • Socket
    • ServerSocket
    • DatagramSocket
    • MulticastSocket

    Send/Receive long/int/short data:
    • DataInputStream
    • DataOutputStream
    • xxx

    Non-block socket
    (Sample: )
    • SocketChannel
    • ServerSocketChannel
  5. URL
    URL: Uniform Resource Locator (统一资源定位符)
    URI: Uniform Resrouce Identifier (统一资源标识符)

    • URLConnection
      A connection to a URL for reading or writing.Built-in Protocols:
      • File
      • Jar
      • Http/Https
      • Ftp

      URL --getConnection-->  URLConnection --setXXX--getInputStream/getOutputStream--> InputStream/OutputStream

    • HttpURLConnection
    • HttpsURLConnection
    • JarURLConnection
    • DownloadManager
      Request to download an URI to a particular destination file in background, and will get notification once the URI is downloaded.
    • xxx

    Encode/Decode
    • URLEncoder
    • URLDecoder
    • EncodingUtils
  6. Apach Library
    • Params/Headers
      Params
      =====================================================================
      Params represents a collection of HTTP protocol and framework parameters.

      From HttpMessage.getParams().

      Classes/Interfaces related to params:
      • HttpParams
      • HttpConnectionParams
        Invoke methods of this class to set params into HttpParams, such as: set socket buffer size, connection time out, retriving data time out, etc.
      • HttpProtocolParams
        Headers of HTTP specific.
        BasicHttpParams, DefaultedHttpParams.
      • xxx


      Headers
      =====================================================================
      Each header field consists of a name followed by a colon (\":\") and the field value. Field names are case-insensitive. he field value MAY be preceded by any amount of LWS, though a single SP is preferred.

      Header is from HttpMessage.getXXXHeaders();

      Classes/interfaces related to header:
      • Header
      • BasicHeader
      • BufferedHeader
        Represents a raw HTTP header whose content is parsed \'on demand\' only when the header value needs to be consumed.
      • FormattedHeader
        An HTTP header which is already formatted. For example when headers are received, the original formatting can be preserved. This allows for the header to be sent without another formatting step.
      • xxx


      Header Elements
      =====================================================================
      Header element is a specific type of value of HTTP header, such value can be decomposed into multiple elements (ie. the set-cookie header:
      Set-Cookie: =[; =]...
      [; expires=][; domain=]
      [; path=][; secure][; httponly]

      (from: %28v=vs.85%29.aspx))
      Header elements is from Header.getElements().

      Classes/Interface related to Header elements:
      • HeaderElement
      • BasicHeaderElement



      Attribute/value pair
      =====================================================================
      From HeaderElement.getParametersXXX(), you can infoke getName/getValue with Attribute/value pair.

      Related classes/interfaces:
      • NameValuePair
      • BasicNameValuePair


      Request Line
      =====================================================================
      The first line of an HttpRequest. It contains the method, URI, and HTTP version of the request.
      Classes/Interfaces:
      • RequestLine
      • BasicRequestLine



      Status
      =====================================================================
      From HttpResponse.getStatusLine().

      Status contains:
      • Protocol version: HTTP/1.0, HTTP/1.1 etc.
      • Status code (Defined in the class HttpStatus)
      • Reason phrase
      • xxx

      Related classes/interfaces:
      • StatusLine
        Represents a status line as returned from a HTTP server.
      • BasicStatusLine
        Used to construct a status line.
      • HttpStatus
        Defines HTTP status codes.
      • xxx


      Version
      =====================================================================
      From HttpMessage.getProtocolVersion(), StatusLine.getProtocolVersion().

      Http version contains (ie HTTP/1.0):
      • Protocol: ie HTTP
      • Major version: ie 1
      • Minor version: ie 0
      • xxx

      Related classes/interfaces:
      • ProtocolVersion
      • HttpVersion
        Defines HTTP protocol name; defines HTTP version 0.9, 1.0, 1.1; Use major and minor version to construct ProtocolVersion.
      • xxx

    • Message

      Http Message
      =====================================================================
      Related classes/interfaces:
      • HttpMessage
      • xxx


      Request
      =====================================================================
      Classes/Interfaces:
      • HttpRequest
      • BasicHttpRequest
      • HttpEntityEnclosingRequest
        Basic implementation of a request with an entity that can be modified.
      • BasicHttpEntityEnclosingRequest
      • HttpUriRequest
      • HttpRequestBase
        1. HttpGet: Download data/file (use getEntity to get data)
        2. HttpPut: Upload data/file (use setEntity to set data)
        3. HttpPost
        4. HttpDelete
        5. HttpTrace
      • xxx

      Constants related to the HTTP protocol is defined in the classes HTTP.



      Response
      =====================================================================
      HttpResponse = HttpClient.execute(HttpRequest);

      Related classes/interfaces
      • HttpResponse/BasicHttpResponse
      • xxx



      Entity
      =====================================================================
      An entity that can be sent or received with an HTTP message, it the contents (data different fromhttp headers). An entity is the optional content of a message. If you need to send an entity, you can provide it for example as a byte array, string, file, or through an arbitrary input stream. If you receive a message with an entity, you typically get that as a basic entity. Entity implementations can be wrapped, for example to buffer the content in memory.

      HttpEntity is got by invoking HttpEntityEnclosingRequest.getEntity or HttpResponse.getEntity, or set by invoking HttpGet.setEntity().

      Various kinds of Entify: http://developer.android.com/reference/org/apache/http/entity/package-summary.html, you can use these classes to construct Entity.
      • StringEntity
      • BasicHttpEntity
      • BufferedHttpEntity
      • ByteArrayEntity
      • EntityTemplate
      • FileEntity
      • InputStreamEntity
      • SerializableEntity
      • StringEntity 
      • HttpEntityWrapper
      • xxx


      Another classes related to Entity:
      • EntityUtils

    • Client
      HTTP clients encapsulate a smorgasbord of objects required to execute HTTP requests.

      Related classes/interfaces:
      • HttpClient
      • DefaultHttpClient

      Other classes to send http request:
      • HttpRequestExecutor
      • xxx
    • Others Classes
      • Host
        1. HttpHost
          hold remote host name, port and scheme.
        2. xxx
      • Date
        1. HttpDateGenerator
      • Buffer
        A resizable byte/char array:
        1. ByteArrayBuffer
        2. CharArrayBuffer
      • Constant
        1. HTTP
          Constants related to the HTTP protocol
        2. xxx
      • Send/Receive long/int/short data
        1. DataInputStream
        2. DataOutputStream
        3. xxx
      • xxx
    • Sample
      HttpParams httpParams = new BasicHttpParams();
      httpParams.setParameters(xxx);
      HttpConnectionParams.setXXX(httpParams, xxx);
      HttpClient httpClient = new DefaultHttpClient(httpParams);
      HttpRequest httpRequest = HttpGet(xxx); //Or call HttpPut/HttpPost;
      //Optional code begin
      HttpEntity httpEntity = new StringHttpEntity(xxxx);  //will upload data
      httpRequest .setEntity(httpEntity);  //httpRequest must be type of HttpPost
      //Optional code end
      HttpResponse httpResponse = httpClient.execute(httpRequest);
      if (httpResponse.getStatusLine().getStatusCode() == 200)
      {
          String strResult = EntityUtils.toString(httpResponse.getEntity());
          //InputStream is = httpResponse.getEntity().getContents();
      }
    • xxx
  7. SSL
    Refer to the package 'javax.net.ssl'.
    • SSLSocket
    • SSLServerSocket
  8. xxx
阅读(1341) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~