Sheet 1
http-proxy-cache-server
  twisted-proxy prototype
    python细节
      raise语句 主动引发 异常
      with ... as ...
        with controlled_execution() as thing:
some code
          with open("x.txt") as f:
data = f.read()
do something with data
      pass语句:
        空语句，什么也不做
    twisted相关
      简介
      twisted vs nodejs
      异步编程
        使用Twisted时，避开使用os.system,避免阻塞
  http proxy基本原理
    http method:
      get
      connect
  linux http工具
    wget
    curl
  download & cache
    实现方法
      twisted receveBuff & write file
      python调用shell，使用wget或curl命令
      urllib &urllib2
        urllib
          提供urlencode的方法
          可接收url
          不可接收Request对象
        urllib2
          既可接收url，又可接受Request对象
  目标分析
    了解twisted框架常用回调函数
    使用python urllib实现一个demo
    将demo整合进twisted中
    将访问的请求写入到一文件中
    每次request时，先扫描文件有木有相同request
  工厂模式
    详见有道云笔记
A CONNECT request urges your proxy to establish an HTTP tunnel to the remote end-point. Usually is it used for SSL connections, though it can be used with HTTP as well (used for the purposes of proxy-chaining and tunneling)
CONNECT www.google.com:443
The above line opens a connection from your proxy to www.google.com on port 443. After this, content that is sent by the client is forwarded by the proxy to www.google.com:443.
If a user tries to retrieve a page http://www.google.com, the proxy can send the exact same request and retrieve response for him, on his behalf.
With SSL(HTTPS), only the two remote end-points understand the requests, and the proxy cannot decipher them. Hence, all it does is open that tunnel using CONNECT, and lets the two end-points (webserver and client) talk to each other directly.