/*
Complete the response with status code
483953
public function completeResponse()
    {
        if (!isset($this->response)) {
            $this->response = array();
        }

        if (is_callable($this->responseCodeHandler)) {
            $responseCodeHandler = $this->responseCodeHandler;
            $responseStatus = $responseCodeHandler();
            if ($responseStatus) {
                $this->response['status'] = $responseStatus;
            }
        }
    }
592878
function done() {
      res.removeListener('finish', onfinish);
      res.removeListener('close', onclose);
      /* eslint no-underscore-dangle: 0 no-param-reassign: 0 */
      ctx.response._startAt = process.hrtime();
      try {
        const line = formatLine(morgan, ctx);
        /* eslint no-console:0 */
        console.info(line);
      } catch (err) {
        /* eslint no-console:0 */
        /* istanbul ignore next */
        console.error(err);
      }
    }
1283725
function done( error, response, data ) {
		var info;
		if ( arguments.length === 1 ) {
			debug( 'No available rate limit information.' );
			return clbk( error );
		}
		debug( 'Request completed.' );

		// Get rate limit information:
		info = ratelimit( response.headers );
		debug( 'Rate limit: %d', info.limit );
		debug( 'Rate limit remaining: %d', info.remaining );
		debug( 'Rate limit reset: %s', (new Date( info.reset*1000 )).toISOString() );

		if ( error ) {
			return clbk( error, null, info );
		}
		clbk( null, data, info );
	}
911433
function complete(reply, query) {
    var suffix = this.level.suffix;

    this.level.find(query, this.max, function found(err, data) {
      reply(err, data.map(function map(row) {
        return {
          name: row.key,
          desc: row.value !== suffix ? row.value : ''
        };
      }));
    });
  }
1017657
function complete(e) {
    clearTimeout(doneTimeout);
    if (!done) { return; }
    var d = done;
    done = null;
    if (e) {
      // test failure
      if (!(e instanceof Error)) {
        e = new Error(e);
      }
      d(e);
    } else {
      // test passed
      d();
    }
  }
95406
public ApiSuccessResponse setCompleted(String id, CompletedData completedData) throws ApiException {
        ApiResponse<ApiSuccessResponse> resp = setCompletedWithHttpInfo(id, completedData);
        return resp.getData();
    }
1271465
@Override
    public void afterCompletion(int status)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "afterCompletion : " + status + " : " + this);

        closeTxEntityManager(ivEm, true);

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "afterCompletion");
    }
1005311
function final(err,response){
  			//console.log(err);
  			//console.log(response);
  			if (err){
  				$scope.showerror=true;
  				$scope.cerr = err.data.error;
  				return 0;
  			}
  			if(response){
  				$scope.showmenu.pub = true;
  				//console.log($scope.showmenu.pub,'pub');
  			}
 		 }
982292
protected function requestFinished()
    {
        $this->onResponse->executeOne($this, true);
        $this->state = self::STATE_ROOT;
        $this->contentLength = -1;
        $this->curChunkSize = null;
        $this->chunked = false;
        $this->eofTerminated = false;
        $this->headers = [];
        $this->rawHeaders = null;
        $this->contentType = null;
        $this->charset = null;
        $this->body = '';
        $this->responseCode = 0;
        $this->reqType = null;
        if (!$this->keepalive) {
            $this->finish();
        }
        $this->checkFree();
    }
1296698
function(url, done) {
  var receive = function(res) {
    if (res.statusCode != 200) {
      var msg = 'Failed to load ' + url + '\n' +
        'HTTP responce status code: ' + res.statusCode
      printError(msg)
      done(new Error(msg))
    } else {
      var content = ''
      res
        .on('end', function() {
          done(null, content)
        })
        .on('readable', function() {
          var chunk = res.read()
          content += chunk.toString()
        })
    }
  }

  try {
    require(url.indexOf('https') === 0 ? 'https' : 'http').get(url, receive).on('error', done)
  } catch (e) {
    done(e)
  }
}
1298378
function status(response) {
  if (response.status >= 200 && response.status < 300) {
    return Promise.resolve(response);
  }

  return Promise.reject(new Error(response.statusText));
}
1017335
private boolean completeResponse(OperationResponse response, Runnable callback) {
    // If the response is null, that indicates an exception occurred. The best we can do is complete
    // the response in sequential order.
    if (response == null) {
      LOGGER.trace("{} - Completing failed request", state.getSessionId());
      callback.run();
      return true;
    }

    // If the response's event index is greater than the current event index, that indicates that events that were
    // published prior to the response have not yet been completed. Attempt to complete pending events.
    long responseEventIndex = response.eventIndex();
    if (responseEventIndex > eventIndex) {
      // For each pending event with an eventIndex less than or equal to the response eventIndex, complete the event.
      // This is safe since we know that sequenced responses should see sequential order of events.
      EventCallback eventCallback = eventCallbacks.peek();
      while (eventCallback != null && eventCallback.request.eventIndex() <= responseEventIndex) {
        eventCallbacks.remove();
        LOGGER.trace("{} - Completing {}", state.getSessionId(), eventCallback.request);
        eventCallback.run();
        eventIndex = eventCallback.request.eventIndex();
        eventCallback = eventCallbacks.peek();
      }

      // If the response event index is still greater than the last sequenced event index, check
      // enqueued events to determine whether any events can be skipped. This is necessary to
      // ensure that a response with a missing event can still trigger prior events.
      if (responseEventIndex > eventIndex) {
        for (EventCallback event : eventCallbacks) {
          // If the event's previous index is consistent with the current event index and the event
          // index is greater than the response event index, set the response event index to the
          // event's previous index.
          if (event.request.previousIndex() <= eventIndex && event.request.eventIndex() >= response.eventIndex()) {
            responseEventIndex = event.request.previousIndex();
            break;
          }
        }
      }
    }

    // If after completing pending events the eventIndex is greater than or equal to the response's eventIndex, complete the response.
    // Note that the event protocol initializes the eventIndex to the session ID.
    if (responseEventIndex <= eventIndex || (eventIndex == 0 && responseEventIndex == state.getSessionId())) {
      LOGGER.trace("{} - Completing {}", state.getSessionId(), response);
      callback.run();
      return true;
    } else {
      return false;
    }
  }
669619
function end(res, code) {
  if (code >= 400) {
    // check res object contains connect/express request and next structure
    if (res.req && res.req.next) {
      var error = new Error(http.STATUS_CODES[code]);
      error.status = code;
      return res.req.next(error);
    }

    // write human-friendly error message
    res.writeHead(code);
    res.end('[' + code + '] ' + http.STATUS_CODES[code]);
    return;
  }

  // just end with no body for 304 responses and such
  res.writeHead(code);
  res.end();
}
674418
function() {
    if (_xhr.readyState === 4) {
      var result = Result(_xhr);
      // ready
      __callback_func('ready')(result, _this);
      // success
      if (_xhr.status === 200) __callback_func('success')(result, _this);
      // fail
      else __callback_func('fail')(result, _this);
    }
  }
253081
function respond () {
  let res = this.res
  let body = this.body
  let code = this.status

  if (this.respond === false) return endContext(this)
  if (res.headersSent || this._finished != null) return

  this.set('server', 'Toa/' + Toa.VERSION)
  if (this.config.poweredBy) this.set('x-powered-by', this.config.poweredBy)
  // ignore body
  if (statuses.empty[code]) {
    // strip headers
    this.body = null
    res.end()
  } else if (this.method === 'HEAD') {
    if (isJSON(body)) this.length = Buffer.byteLength(JSON.stringify(body))
    res.end()
  } else if (body == null) {
    // status body
    this.type = 'text'
    body = this.message || String(code)
    this.length = Buffer.byteLength(body)
    res.end(body)
  } else if (typeof body === 'string' || Buffer.isBuffer(body)) {
    res.end(body)
  } else if (body instanceof Stream) {
    body.pipe(res)
    // to ensure `res.headersSent === true` before `context.emit("end")`
    // if "error" occured before "data", it will goto `onResError(this, error)`
    body.once('data', () => endContext(this))
    return
  } else {
    // body: json
    body = JSON.stringify(body)
    this.length = Buffer.byteLength(body)
    res.end(body)
  }
  endContext(this)
}
1363541
synchronized void onComplete(@javax.annotation.Nullable Throwable error) {
    if (isCompleted()) {
      return;
    }
    currentConfigObserver = null;
    // TODO(songya): add Runnable
    Status status;
    if (error == null) {
      status = Status.OK;
    } else if (error instanceof StatusRuntimeException) {
      status = ((StatusRuntimeException) error).getStatus();
    } else {
      status = Status.UNKNOWN;
    }
    terminateStatus = status;
  }
347798
@Override
    public void afterCompletion(int status) {
        if (status == Status.STATUS_COMMITTED)
            controller.notifyOfTaskAssignment(partitionId, taskId, expectedExecTime, binaryFlags, txTimeout);
    }