Two things to do here: 1) collect data and 2) what to do with it when we're done (create response).
171237
function on_connect(res){
	//console.log('STATUS: ' + res.statusCode);
	//console.log('HEADERS: ' + JSON.stringify(res.headers));
	res.setEncoding('utf8');
	var raw_data = '';
	res.on('data', function (chunk) {
	    //console.log('BODY: ' + chunk);
	    raw_data = raw_data + chunk;
	});
	// Throw to .
	res.on('end', function () {
	    //console.log('END with: ' + raw_data);
	    var response = new anchor._response_handler(raw_data);
	    if( response && response.okay() ){
		anchor.apply_callbacks('success', [response, anchor]);
	    }else{
		// Make sure that there is something there to
		// hold on to.
		if( ! response ){
		    response = new anchor._response_handler(null);
		    response.okay(false);
		    response.message_type('error');
		    response.message('null response');
		}else{
		    response.message_type('error');
		    response.message('bad response');
		}
		anchor.apply_callbacks('error', [response, anchor]);
	    }
	});
    }
561019
def process_response(self, request, response, resource, req_succeeded):
        """"""
        self.logger.info(self._generate_combined_log(request, response))
515690
function(response) {
        var chunks = [];

        response.on('data', function(chunk) {
            chunks.push(chunk);
        });

        response.on('end', function() {
            var json = JSON.parse(chunks.join(''));
            this._showOutputInfo(json);
            this._handleOutput(json);
        }.bind(this));
    }
896435
def _do_post_request_tasks(self, response_data):
        
        try:
            sess_ops = response_data.get('ops', [])
        except AttributeError:
            pass
        else:
            self._session_ops.extend(sess_ops)
455579
def and_return(response=nil, &block)
      new_response = (response.nil? ? block : response)
      responses.push(*new_response)
    end
637457
private void handleConnectResponse(ConnectResponse response, Throwable error, CompletableFuture<Connection> future) {
    if (open) {
      if (error == null) {
        LOGGER.trace("{} - Received {}", id, response);
        // If the connection was successfully created, immediately send a keep-alive request
        // to the server to ensure we maintain our session and get an updated list of server addresses.
        if (response.status() == Response.Status.OK) {
          selector.reset(response.leader(), response.members());
          future.complete(connection);
        } else {
          connect(future);
        }
      } else {
        LOGGER.debug("{} - Failed to connect! Reason: {}", id, error);
        connect(future);
      }
    }
  }
541174
def save_and_respond(resource, options={}, &block)
      creation = resource.new_record?
      resource.attributes = options[:attributes] unless options[:attributes].nil?
      respond_to do |format|
        # if ((block_given? and block.arity == 1) ? yield(resource) : (block_given? and block.arity == 2) ? yield(resource, format) : resource.save)
        if (block_given? ? yield(resource, format) : resource.save)
          status = (creation ? :created : :ok)
          response.headers["X-Return-Code"] = "success"
          response.headers["X-Saved-Record-Id"] = resource.id.to_s
          format.html { params[:dialog] ? head(status) : redirect_to(options[:url] || resource) }
          format.json { render :json => resource.to_json, :status => status, :location => resource}
          format.xml  { render  :xml => resource.to_xml,  :status => status, :location => resource }
        else
          response.headers["X-Return-Code"] = "invalid"
          format.html { render :action => (resource.new_record? ? "new" : "edit")}
          format.json { render :json => resource.errors.to_json, :status => :unprocessable_entity }
          format.xml  { render  :xml => resource.errors.to_xml,  :status => :unprocessable_entity }
        end
      end
    end
1057551
function (response) {
            response = JSON.parse(response).result;
            response.stdout.forEach(function (val, index, array) {
                if (val == answers[index]) {
                    results.push(true);
                } else {
                    results.push(false);
                }
            });
            callback({
                results: results,
                message: response.message,
                time: response.time
            });
        }
294749
def dispatch(self, request, **kwargs):
        '''
        
        '''

        # Check if this is a REST query to pusth the answer to responde in JSON
        if bool(self.request.META.get('HTTP_X_REST', False)):
            self.json = True

        # Check if this is a REST query to add an element
        if self.request.method in ['PUT', 'DELETE']:
            if self.request.method == 'PUT':
                action = 'edit'
            else:
                action = 'delete'

            # Set new method
            self.request.method == 'POST'

            # Find the URL
            target = get_class(resolve("{}/{}".format(self.request.META.get("REQUEST_URI"), action)).func)

            # Make sure we will answer as an API
            target.json = True

            # Lets go for it
            return target.as_view()(self.request, pk=kwargs.get('pk'))

        # Detect if we have to answer in json
        self.__authtoken = (bool(getattr(self.request, "authtoken", False)))
        self.json_worker = self.__authtoken or (self.json is True)

        # Check if this is an AJAX request
        if (request.is_ajax() or self.json_worker) and request.body:
            request.POST = json.loads(request.body)

        # Set class internal variables
        self._setup(request)

        # Call the base implementation
        return super(GenDetail, self).dispatch(request, **kwargs)
133210
def _handle_create(self, response, ignore_tombstone, auto_refresh):

		'''
		
		'''

		# 201, success, refresh
		if response.status_code == 201:
			# if not specifying uri, capture from response and append to object
			self.uri = self.repo.parse_uri(response.text)
			# creation successful
			if auto_refresh:
				self.refresh()
			elif auto_refresh == None:
				if self.repo.default_auto_refresh:
					self.refresh()
			# fire resource._post_create hook if exists
			if hasattr(self,'_post_create'):
				self._post_create(auto_refresh=auto_refresh)

		# 404, assumed POST, target location does not exist
		elif response.status_code == 404:
			raise Exception('HTTP 404, for this POST request target location does not exist')

		# 409, conflict, resource likely exists
		elif response.status_code == 409:
			raise Exception('HTTP 409, resource already exists')

		# 410, tombstone present
		elif response.status_code == 410:
			if ignore_tombstone:
				response = self.repo.api.http_request('DELETE', '%s/fcr:tombstone' % self.uri)
				if response.status_code == 204:
					logger.debug('tombstone removed, retrying create')
					self.create()
				else:
					raise Exception('HTTP %s, Could not remove tombstone for %s' % (response.status_code, self.uri))
			else:
				raise Exception('tombstone for %s detected, aborting' % self.uri)

		# 415, unsupported media type
		elif response.status_code == 415:
			raise Exception('HTTP 415, unsupported media type')

		# unknown status code
		else:
			raise Exception('HTTP %s, unknown error creating resource' % response.status_code)

		# if all goes well, return self
		return self
237488
def _post_create(atdepth, entry, result):
    
    if not atdepth and entry is not None:
        if result is not None:
            #We need to get these results a UUID that will be saved so that any
            #instance methods applied to this object has a parent to refer to.
            retid = _tracker_str(result)
            entry["r"] = retid
            ekey = retid
        else: # pragma: no cover
            ekey = _tracker_str(cls)

        msg.info("{}: {}".format(ekey, entry), 1)
        record(ekey, entry)
1219232
function onResponse( response ) {
		res = response;
		if ( res.statusCode !== 200 ) {
			err = {
				'status': res.statusCode,
				'message': ''
			};
		}
		debug( 'Received a response from query endpoint.' );
		debug( 'Response status: %s.', res.statusCode );

		debug( 'Response headers: %s', JSON.stringify( res.headers ) );

		res.setEncoding( 'utf8' );
		res.on( 'data', onData );
		res.on( 'end', onEnd );
	}
1040395
function(request_data, response_hook) {
	    anchor.jq_vars['success'] = function(json_data){
		var retlist = [];
		var resp = new bbop.golr.response(json_data);

		// Reset the last return; remember: tri-state.
		result_count = null;
		return_count = null;

		if( resp.success() ){

		    // Get best shot at document counts.
		    result_count = resp.total_documents();
		    return_count = resp.documents().length;

		    loop(resp.documents(),
			 function(doc){

			     // First, try and pull what we can out of our
			     var lbl = label_tt.fill(doc);

			     // Now the same thing for the return/value.
			     var val = value_tt.fill(doc);

			     // Add the discovered items to the return
			     // save.
			     var item = {
				 'label': lbl,
				 'value': val,
				 'document': doc
			     };
			     retlist.push(item);
			 });
		}
		response_hook(retlist);
	    };

	    // Get the selected term into the manager and fire.
	    //anchor.set_query(request_data.term);
	    anchor.set_comfy_query(request_data.term);
	    anchor.JQ.ajax(anchor.get_query_url(), anchor.jq_vars);
	}
1039782
def _makeResponse(self, urllib2_response):
        '''
        
        '''
        resp = HTTPResponse()
        resp.body = urllib2_response.read(MAX_RESPONSE_KB * 1024)
        resp.final_url = urllib2_response.geturl()
        resp.headers = self._lowerCaseKeys(
            dict(list(urllib2_response.info().items())))

        if hasattr(urllib2_response, 'code'):
            resp.status = urllib2_response.code
        else:
            resp.status = 200

        _, extra_dict = self._parseHeaderValue(
            resp.headers.get("content-type", ""))
        # Try to decode the response body to a string, if there's a
        # charset known; fall back to ISO-8859-1 otherwise, since that's
        # what's suggested in HTTP/1.1
        charset = extra_dict.get('charset', 'latin1')
        try:
            resp.body = resp.body.decode(charset)
        except Exception:
            pass

        return resp
676056
def response_add(self, request, obj, post_url_continue=POST_URL_CONTINUE):
        
        if '_addanother' not in request.POST and '_popup' not in request.POST:
            request.POST['_continue'] = 1
        return super(ExportAdmin, self).response_add(request,
                                                     obj,
                                                     post_url_continue)
1362313
def post(self):
		
		data = json.loads(self.request.body.decode())
		response = dispatch([log],{'jsonrpc': '2.0', 
					'method': 'log', 'params': data, 'id': 1})
309159
def on_finish(self):
        
        r = self.response
        r.request_time = time.time() - self.start_time
        if self.callback:
            self.callback(r)