初始化Response对象

@param res 响应对象
350967
protected final static void init(HttpServletResponse res) {
		// -- 字符集的过滤
		String charset = HuluSetting.charset;
		try {
			res.setCharacterEncoding(charset);
		} catch (Exception e) {
			log.warn("Charset [{}] not support!", charset);
		}
		responseThreadLocal.set(res);
	}
59481
function(err, res) {
        if (err) return callback(err);
        self._rawResponse = res;
        if (!res || !res['cps:reply']) return callback(new Error("Invalid reply"));
        self.seconds = res['cps:reply']['cps:seconds'];
        if (res['cps:reply']['cps:content']) {
            var content = res['cps:reply']['cps:content'];
            self = _.merge(self, content);
        }

        callback(res['cps:reply']['cps:error'], self);
    }
1297624
function (res, args) {

            var resFromFilters = args.res;

            // set final error flag
            if (resFromFilters.errorData) {
                res.error = true;
            }

            // resFromFilters as precedence over handler response
            if (resFromFilters.data) {
                res.data = resFromFilters.data;
            }

            if (resFromFilters.errorData) {
                res.errorData = resFromFilters.errorData;
            }

            if (res.error) {
                var errorEvt = {
                    name : "error",
                    requestUrl : resFromFilters.requestUrl,
                    requestObject : args.requestObject,
                    errorData : res.errorData
                };

                // add HTTP errors if any
                if (resFromFilters.error) {
                    errorEvt.httpError = {
                        error : resFromFilters.error,
                        status : resFromFilters.status
                    };
                }
                this.$raiseEvent(errorEvt);
            }

            // finish by calling the requester callback
            this.$callback(args.cb, res, this.CALLBACK_ERROR);
        }
1165621
public void initForNextResponse(IResponse res) {
		logger.logp(Level.FINE, CLASS_NAME,"initForNextResponse", nls.getString("Illegal.from.included.servlet", "Illegal from included servlet"), "initForNextResponse");
		
	}
1340452
protected void doResponse(javax.servlet.sip.SipServletResponse resp) throws javax.servlet.ServletException, java.io.IOException{
    	int status = resp.getStatus();
		if (status < 200) {
			doProvisionalResponse(resp);
		} else {			
			if (status < 300) {
				doSuccessResponse(resp);
			} else if (status < 400) {
				doRedirectResponse(resp);
			} else {	
				doErrorResponse(resp);
			}				
		}
    }
48272
function getResponseStatusCode (res) {
  var status = res.statusCode

  // default status code to 500 if outside valid range
  if (typeof status !== 'number' || status < 400 || status > 599) {
    status = 500
  }

  return status
}
734429
function responseHandler (res, next) {
  return function (err, message) {
    if (err || !message) {
      next(err);
    } else {
      res.send(message);
    }
  }
}
274105
private function parseResponse($res) {
    $contents = explode("\n", $res);

    // Response comes back as HTTP/1.1 200 OK
    // Final line contains HTTP response.
    $status = explode(" ", $contents[0], 3);
    $result = $contents[count($contents) - 1];

    return array(
      "status"  => isset($status[1]) ? $status[1] : null,
      "message" => $result
    );
  }
487540
public final boolean handle(HttpServletRequest req, HttpServletResponse res) {
		return handle(req, res, Request.getPath(req));
	}
1299232
private String processUploadResponse(Response res) throws QiniuException {
		if (res.isOK()) {
			UploadResult ret = res.jsonToObject(UploadResult.class);
			return getFullPath(ret.key);
		}
		throw new FSOperErrorException(name(), res.toString());
	}
715560
function(req, res, response) {

  if (response.status === 302) {
    var location = response.headers.location;
    delete response.headers.location;
    res.set(response.headers);
    res.redirect(location);
  } else {
    res.set(response.headers);
    res.status(response.status).send(response.body);
  }
}
530574
function respOk (response, data, type) {
    if (type) {
        headers = {'Content-Type': type};
    }
    response.writeHead(200, headers);
    if (data) {
        response.write(data, 'utf-8');
    }
    response.end();
}
615268
function handler(req, res) {

  var parsedUrl = url.parse(req.url)
  var callback = qs.parse(parsedUrl.query).callback
  var filename = decodeURI(parsedUrl.path.substr(1).split('?')[0])
  var basename = path.basename(filename.split('?')[0])
  var extname = path.extname(basename)
  var response = reswrap(res);
  var notfound = function() {
    response.writeHead(404, 'text').end('');
  };

  if (req.method === 'GET' && parsedUrl.pathname === '/jsonp-request') {
    if (!!exitCountdown) {
      exitCountdown.restart();
    }

    response
      .writeHead(200, 'js')
      .end(callback +'('+ R.get('stamp') +')');

    return;
  }

  var serve;
  if (/^\/template/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  } else if (/^\/node_modules/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  }
  if (serve) {
    serve.pass(function(name, type) {
      response
        .writeHead(200, extname.substr(1))
        .pipeWith(fs.createReadStream(
          path.resolve(name)
        ))
    }).fail(notfound);
    return;
  }

  if (/^\.(md|mkd|markdown|html)$/.test(extname)) {
    check(filename)
      .pass(function() {
        response
          .writeHead(200, 'html')
          .end(template.render({
            title: basename,
            highlight: R.get('highlight') || 'default',
            theme: getTheme(R.get('css')),
            width: R.get('width'),
            body: parser.parse(read(path.resolve(filename)))
          }));
      }).fail(notfound);

    return;
  }

  // Image or some other resources.
  check(filename)
    .pass(function(name) {
      response
        .writeHead(200, name)
        .pipeWith(fs.createReadStream(name));
    }).fail(notfound)
}
1298777
function(res) {
      // handle thumbnail
      var picurl = '';
      // TODO: further process to thumbnail according to its size
      if (!res.thumbnail) {
        // if no thumbnail exists, a default pic should be returned.
        picurl = this.conf.CONST.PIC_PLACEHOLDER;
      } else {
        picurl = res.thumbnail.source;
      }
      res.extract = _.trunc(res.extract, {
        'length': this.conf.CONST.EXTRACT_REPLY_LIMIT, 
        'separator': /(，|。|\n)/
      });
      return {
        title: res.title,
        description: res.extract,
        url: this._page_url(res.title),
        picurl: picurl
      };
    }
779562
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    private static Iterable<String> extend(final Response res,
        final Iterable<? extends CharSequence> headers) throws IOException {
        Response resp = res;
        for (final CharSequence hdr: headers) {
            resp = new RsWithHeader(resp, hdr);
        }
        return resp.head();
    }
458134
function onResponse (res) {
      endTime = getTimeMs(endTime)

      res = Object.assign(res, { opDuration: endTime })

      if (res.error) {
        appendRes = res
      } else {
        log.info(
          {
            res: res,
            duration: endTime
          },
          'end of the request'
        )
      }
    }
581890
function(res) {
    res.setEncoding('utf8');
    var data = "";
    res.on('data', function(chunk) {
      data+=chunk;
    });

    res.on('end', function() {
      // Get HTTP Statuscode and act according to situation
      var code = res.statusCode;
      try { // try to parse JSON
        var answer = JSON.parse(data);
      } catch (e) {
        var err = {};
        err.http_code = 500;
        err.message = "No valid JSON received: "+data;
        callback(err, null);
        return;
      }
      if(code >= 200 && code <= 206) { // request was successful
        callback(null, answer);
      } else if (code >= 300 && code <= 307) { // server send redirect
        // we do not follow anything the server wants us to follow right now, since this should never be the case.
        // instead let's raise an error.
        var err = new Object();
        err.http_code = 500;
        err.message = "Redirects not supported by pastyclient-node"
        callback(err, null);
      } else if (code >= 400 && code <= 418) { // client error
        if(typeof(answer.error) == "object") {
          var err = answer.error;
        } else if(answer.code != undefined && answer.message != undefined) { // New RestError, temporary support both 
          var err = answer;
          err.http_code = code;
        } else {
          var err = new Object();
          err.http_code = code;
          err.message = "Resource not found";
        }
        callback(err, null);
      } else if (code >= 500 && code <= 505) { // server error
        if(typeof(answer.error) == "object") {
          var err = answer.error;
        } else {
          var err = new Object();
          err.http_code = code;
          err.message = "Internal Server Error";
        }
        callback(err, null);
      } else {
        // Not existant HTTP code. Raise error.
        var err = new Object();
        err.http_code = 500;
        err.message = "HTTP Status Code "+code+" is not supported by pastyclient-node"
        callback(err, null);
      }
    });
  }