Handles an Atom GET by calling handler and writing results to response.
433312
@Override
    protected void doGet(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
        LOG.debug("Entering");
        final AtomHandler handler = createAtomRequestHandler(req, res);
        final String userName = handler.getAuthenticatedUsername();
        if (userName != null) {
            final AtomRequest areq = new AtomRequestImpl(req);
            try {
                if (handler.isAtomServiceURI(areq)) {
                    // return an Atom Service document
                    final AtomService service = handler.getAtomService(areq);
                    final Document doc = service.serviceToDocument();
                    res.setContentType("application/atomsvc+xml; charset=utf-8");
                    final Writer writer = res.getWriter();
                    final XMLOutputter outputter = new XMLOutputter();
                    outputter.setFormat(Format.getPrettyFormat());
                    outputter.output(doc, writer);
                    writer.close();
                    res.setStatus(HttpServletResponse.SC_OK);
                } else if (handler.isCategoriesURI(areq)) {
                    final Categories cats = handler.getCategories(areq);
                    res.setContentType("application/xml");
                    final Writer writer = res.getWriter();
                    final Document catsDoc = new Document();
                    catsDoc.setRootElement(cats.categoriesToElement());
                    final XMLOutputter outputter = new XMLOutputter();
                    outputter.output(catsDoc, writer);
                    writer.close();
                    res.setStatus(HttpServletResponse.SC_OK);
                } else if (handler.isCollectionURI(areq)) {
                    // return a collection
                    final Feed col = handler.getCollection(areq);
                    col.setFeedType(FEED_TYPE);
                    final WireFeedOutput wireFeedOutput = new WireFeedOutput();
                    final Document feedDoc = wireFeedOutput.outputJDom(col);
                    res.setContentType("application/atom+xml; charset=utf-8");
                    final Writer writer = res.getWriter();
                    final XMLOutputter outputter = new XMLOutputter();
                    outputter.setFormat(Format.getPrettyFormat());
                    outputter.output(feedDoc, writer);
                    writer.close();
                    res.setStatus(HttpServletResponse.SC_OK);
                } else if (handler.isEntryURI(areq)) {
                    // return an entry
                    final Entry entry = handler.getEntry(areq);
                    if (entry != null) {
                        res.setContentType("application/atom+xml; type=entry; charset=utf-8");
                        final Writer writer = res.getWriter();
                        Atom10Generator.serializeEntry(entry, writer);
                        writer.close();
                    } else {
                        res.setStatus(HttpServletResponse.SC_NOT_FOUND);
                    }
                } else if (handler.isMediaEditURI(areq)) {
                    final AtomMediaResource entry = handler.getMediaResource(areq);
                    res.setContentType(entry.getContentType());
                    res.setContentLength((int) entry.getContentLength());
                    Utilities.copyInputToOutput(entry.getInputStream(), res.getOutputStream());
                    res.getOutputStream().flush();
                    res.getOutputStream().close();
                } else {
                    res.setStatus(HttpServletResponse.SC_NOT_FOUND);
                }
            } catch (final AtomException ae) {
                res.sendError(ae.getStatus(), ae.getMessage());
                LOG.debug("An error occured while processing GET", ae);
            } catch (final Exception e) {
                res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
                LOG.debug("An error occured while processing GET", e);
            }
        } else {
            res.setHeader("WWW-Authenticate", "BASIC realm=\"AtomPub\"");
            res.sendError(HttpServletResponse.SC_UNAUTHORIZED);
        }
        LOG.debug("Exiting");
    }
734429
function responseHandler (res, next) {
  return function (err, message) {
    if (err || !message) {
      next(err);
    } else {
      res.send(message);
    }
  }
}
1327590
@Override
    public void handle(T result, HttpResponse response) {
        String transitionHeader = response.getHeaders().get(Headers.IBM_TRANSITION);
        if (transitionHeader != null) {
            result.setTransitionDate(parseDate(transitionHeader));
            String transition = parseTransition(transitionHeader);
            if (transition != null) {
                result.setTransition(transition);
            }
        }
    }
161273
async function handleCallError (result) {
  const error = Buffer.from(result.returnValue).toString()
  if (isBase64(error.slice(3))) {
    const decodedError = Buffer.from(error.slice(3), 'base64').toString()
    throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error, decodedError }))
  }

  const decodedError = await this.contractDecodeData('string', error)
  throw Object.assign(Error(`Invocation failed: ${error}. Decoded: ${decodedError}`), R.merge(result, { error, decodedError }))
}
281210
def call_handler(self):
        ''''''
        if self.handler is None:
            return
        call = getattr(self.handler, 'call', None)
        if call is not None:
            self.handler_result = call()
1029801
public function handleResult()
    {
        // No result
        $result = $this->worker->getResult();
        if ($result === null) {
            return;
        }

        // Invalid worker state, wait for a response first.
        if (!$this->isWorkerHandlerReady()) {
            return;
        }

        $this->sendToWorkerHandler(new Protocol\JobResult($this->worker->getRequestId(), $result));
        $this->worker->setState(Worker::RESULT);
    }
1354362
private void handleResponse(PowerShellResponseHandler response, PowerShellResponse powerShellResponse) {
        try {
            response.handle(powerShellResponse);
        } catch (Exception ex) {
            logger.log(Level.SEVERE, "PowerShell not available", ex);
        }
    }
822615
def _handle_api(self, handler, handler_args, handler_kwargs):
        
        try:
            status_code, return_value = handler(*handler_args, **handler_kwargs)
        except APIError as error:
            return error.send()

        web.ctx.status = _convert_http_status(status_code)
        return _api_convert_output(return_value)
986094
def _on_request(self, name, args):
        """"""
        if IS_PYTHON3:
            name = decode_if_bytes(name)
        handler = self._request_handlers.get(name, None)
        if not handler:
            msg = self._missing_handler_error(name, 'request')
            error(msg)
            raise ErrorResponse(msg)

        debug('calling request handler for "%s", args: "%s"', name, args)
        rv = handler(*args)
        debug("request handler for '%s %s' returns: %s", name, args, rv)
        return rv
1039652
def handle_response(defopts, res)
      raise NetError.new(res.body)  unless res.code == '200'

      json = Yajl::Parser.parse(res.body)
      RegApi2.got_response(json)

      raise ApiError.from_json(json)  if json['result'] == 'error'

      res_contract = RegApi2::ResultContract.new(defopts)
      res_contract.handle_result(json)
    end
320899
def make_response(obj):
    """"""
    if obj is None:
        raise TypeError("Handler return value cannot be None.")
    if isinstance(obj, Response):
        return obj
    return Response(200, body=obj)
217721
def on_get(self, request, response, user_id=None):
        """"""
        response.body = "{}"
        if self.handler(user_id):
            response.status = falcon.HTTP_200
            self.api.register(utils.mxid2localpart(user_id))
        else:
            response.status = falcon.HTTP_404
1004060
def handleRequest(self, req):
        """"""
        name = req["method"]
        params = req["params"]
        id=req["id"]
        obj=None
        try: #to get a callable obj 
            obj = getMethodByName(self.service, name)
        except MethodNameNotAllowed,e:
            self.sendResponse(id, None, e)
        except:
            self.sendResponse(id, None, MethodNotFound())
        if obj:
            try: #to call the object with parameters
                rslt = obj(*params)
                self.sendResponse(id, rslt, None)
            except TypeError: # wrong arguments
                #todo what if the TypeError was not thrown directly by the callable obj
                s=getTracebackStr()
                self.sendResponse(id, None, InvalidMethodParameters())
            except: #error inside the callable object
                s=getTracebackStr()
                self.sendResponse(id, None, s)
721202
def _handle_response(self, response):
        
        if not response.ok:
            raise ScrapydResponseError(
                "Scrapyd returned a {0} error: {1}".format(
                    response.status_code,
                    response.text))

        try:
            json = response.json()
        except ValueError:
            raise ScrapydResponseError("Scrapyd returned an invalid JSON "
                                       "response: {0}".format(response.text))
        if json['status'] == 'ok':
            json.pop('status')
            return json
        elif json['status'] == 'error':
            raise ScrapydResponseError(json['message'])
441952
async def handler(event):
    """"""
    query = urllib.parse.quote(event.pattern_match.group(1))
    await asyncio.wait([
        event.delete(),
        event.respond(SEARCH.format(query), reply_to=event.reply_to_msg_id)
    ])
1003541
public void handleGet(HttpServletRequest request, HttpServletResponse response, String pathInContext, Resource resource, boolean endsWithSlash) throws ServletException, IOException
    {
        if (resource == null || !resource.exists())
            response.sendError(HttpResponse.__404_Not_Found);
        else
        {

            // check if directory
            if (resource.isDirectory())
            {
                if (!endsWithSlash && !pathInContext.equals("/"))
                {
                    String q = request.getQueryString();
                    StringBuffer buf = request.getRequestURL();
                    if (q != null && q.length() != 0)
                    {
                        buf.append('?');
                        buf.append(q);
                    }
                    response.setContentLength(0);
                    response.sendRedirect(response.encodeRedirectURL(URI.addPaths(buf.toString(), "/")));
                    return;
                }

                // See if index file exists
                String welcome = _httpContext.getWelcomeFile(resource);
                if (welcome != null)
                {
                    String ipath = URI.addPaths(pathInContext, welcome);
                    if (_redirectWelcomeFiles)
                    {
                        // Redirect to the index
                        response.setContentLength(0);
                        response.sendRedirect(URI.addPaths(_httpContext.getContextPath(), ipath));
                    }
                    else
                    {
                        // Forward to the index
                        RequestDispatcher dispatcher = _servletHandler.getRequestDispatcher(ipath);
                        dispatcher.forward(request, response);
                    }
                    return;
                }

                // Check modified dates
                if (!passConditionalHeaders(request, response, resource))
                    return;

                // If we got here, no forward to index took place
                sendDirectory(request, response, resource, pathInContext.length() > 1);
            }
            else
            {
                // Check modified dates
                if (!passConditionalHeaders(request, response, resource))
                    return;

                // just send it
                sendData(request, response, pathInContext, resource);
            }
        }
    }
1298816
def get(self, receiver_id=None, event_id=None):
        """"""
        event = self._get_event(receiver_id, event_id)
        return make_response(event)