A new instance of Server.
 @param [Proc, #call] request_handler proc which implements the pingback registration and takes the source_uri and the target_uri
     as params. Use the exceptions defined in Pingback to indicate errors.
962827
def call(env)
      @request = Rack::Request.new(env)
      xml_response = @xmlrpc_handler.process(request_body)
      [200, {'Content-Type' => 'text/xml'}, [xml_response]]
    end
894265
public URLStreamHandler createURLStreamHandler (String protocol)
    {
        Class<? extends URLStreamHandler> handler = _handlers.get(protocol.toLowerCase());
        if (handler != null) {
            try {
                return handler.newInstance();
            } catch (Exception e) {
                log.warning("Unable to instantiate URLStreamHandler", "protocol", protocol,
                            "cause", e);
            }
        }
        return null;
    }
754231
final void addHandler(final HttpHandler handler) {
    if (handler != null) {
      if (!eventHandlers.containsKey(handler.getUriSpecification().toLowerCase())) {
        eventHandlers.put(handler.getUriSpecification().toLowerCase(), handler);
      } else {
        LOG.log(Level.WARNING, "JettyHandler handle is already registered: {0} ", handler.getUriSpecification());
      }
    }
  }
1246313
def request(self, host, handler, request_body, verbose):
        ''''''
        #We get a traceback if we don't have this attribute:
        self.verbose = verbose
        url = 'http://' + host + handler
        request = urllib2.Request(url)
        request.add_data(request_body)
        # Note: 'Host' and 'Content-Length' are added automatically
        request.add_header('User-Agent', self.user_agent)
        request.add_header('Content-Type', 'text/xml')
        proxy_handler = urllib2.ProxyHandler()
        opener = urllib2.build_opener(proxy_handler)
        fhandle = opener.open(request)
        return(self.parse_response(fhandle))
1049695
public function process(Request $request, Handler $handler): Response
    {
        $method = $request->getMethod();
        $uri = $request->getUri()->getPath() ?: '/';

        $routeInfo = $this->getDispatcher()->dispatch($method, $uri);

        switch ($routeInfo[0]) {
            case Dispatcher::NOT_FOUND:
                throw new RouteNotFoundException($uri);
            case Dispatcher::METHOD_NOT_ALLOWED:
                throw new MethodNotAllowedException($method);
            case Dispatcher::FOUND:
                $handler = $routeInfo[1];
                $parameters = $routeInfo[2];

                return $handler($request, $parameters);
        }
    }
678541
async def handle_request(self, request: Request) -> Response:
        
        # Get handler
        try:
            try:
                self._set_ctx(request)
                handler = self.router.get_handler_for_request(request)
                request.app = self
                response = await handler(request)
                response.app = self
            except ResponseError as r:
                parser = app_parsers.get(request.content_type, None)

                # Content-Type of an error response will be the same as the incoming request
                # unless a parser for that content type is not found.
                if not parser:
                    content_type = r.content_type
                    if not content_type:
                        content_type = self.default_content_type
                else:
                    content_type = request.content_type
                response = Response(
                    headers=r.headers, correlation_id=r.correlation_id, body=r.body,
                    status=r.status, content_type=content_type
                )
                response.app = self
                if r.log:
                    exc_info = sys.exc_info()
                    self.logger.log_exception(request, exc_info, level='warning')
            # invoke serialization (json) to make sure it works
            _ = response.body

        except CancelledError:
            # This error can happen if a client closes the connection
            # The response shouldnt really ever be used
            return None

        except asyncio.TimeoutError:
            response = Response(status=HTTPStatus.GATEWAY_TIMEOUT,
                                body={'message': 'Gateway Timeout'})
            response.app = self

        except NackMePleaseError:
            """ See message where this error is defined """
            raise

        except Exception:
            exc_info = sys.exc_info()
            self.logger.log_exception(request, exc_info)
            response = Response(status=HTTPStatus.INTERNAL_SERVER_ERROR,
                                body={'message': 'Server Error'})
            response.app = self
        if not response.correlation_id:
            response.correlation_id = request.correlation_id

        if self._cors_handler is not None:
            self._cors_handler.add_cors_headers(request, response)

        # add default headers
        response.headers = {**self.default_headers, **response.headers}

        return response
1355471
def example_exc_handler(tries_remaining, exception, delay):
    
    print >> sys.stderr, "Caught '%s', %d tries remaining, sleeping for %s seconds" % (
        exception, tries_remaining, delay)
1081743
def init_handler(args):
    
    try:
        initialize_repository(pathlib.Path.cwd())
    except ValueError as exc:
        print(exc, file=sys.stderr)
        return ExitCode.DATAERR

    return ExitCode.OK
593598
public BaseRequestHandler loadHandler(String handlerClassName, String uri)
      throws
      ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
      InvocationTargetException, InstantiationException {
    Class<? extends BaseRequestHandler> handlerClass =
        classLoader.loadClass(handlerClassName).asSubclass(BaseRequestHandler.class);
    Constructor<? extends BaseRequestHandler> constructor =
        handlerClass.getConstructor(String.class);
    return constructor.newInstance(uri);
  }
178201
private static void initMapDefinedHandler(Map<String, Object> handler) {
		// If the handler is a map, the keys are the class name, values are the
		// parameters.
		for (Map.Entry<String, Object> entry : handler.entrySet()) {
			Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());

			// If the values in the config are a map, construct the object using named
			// parameters.
			if (entry.getValue() instanceof Map) {
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
							(Map) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a map: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			} else if (entry.getValue() instanceof List) {

				// If the values in the config are a list, call the constructor of the handler
				// with those fields.
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
							(List) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a list: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			}
		}
	}
471068
def params_handler_default(params_handler)
      params_handler[:require] = (self.class.entity_required || route_key(@klass)) unless params_handler.has_key?(:require)
      params_handler[:permit] = self.class.entity_attributes unless params_handler.has_key?(:permit)
      params_handler
    end
446869
def process_request(control, sym, args)
      instance = factory.call(control)

      instance.send(sym, *args)
    end
1130301
def add_exception_handler(self, exception_handler):
        # type: (AbstractExceptionHandler) -> None
        
        if exception_handler is None:
            raise RuntimeConfigException(
                "Valid Exception Handler instance to be provided")

        if not isinstance(exception_handler, AbstractExceptionHandler):
            raise RuntimeConfigException(
                "Input should be an ExceptionHandler instance")

        self.exception_handlers.append(exception_handler)
154844
def pingback_url(self, server_name, target_url):
        
        try:
            server = ServerProxy(server_name)
            reply = server.pingback.ping(self.entry_url, target_url)
        except (Error, socket.error):
            reply = '%s cannot be pinged.' % target_url
        return reply
301169
function createHandler(to, except, pathFunc, protocol) {
    return function(req, res, next) {
        var host = req.hostname || '';
        var url = req.url;

        if (host in except) {
            next();
        } else {
            var target = new URIjs(pathFunc(host, url))
              .host(to)
              .protocol(protocol || '')
              .href();

            res.redirect(301, target);
        }
    };
}
280974
def request(self, request_type):
        '''  '''

        def _handler(func):
            self._handlers[request_type] = func
            return func

        return _handler
1058095
public static final ChannelInitializer<Channel> httpClient(
      final SimpleChannelInboundHandler<HttpResponse> handler) {
    return new ChannelInitializer<Channel>() {

      @Override
      protected void initChannel(Channel channel) throws Exception {
        ChannelPipeline pipeline = channel.pipeline();
        pipeline.addLast("httpCodec", new HttpClientCodec());
        pipeline.addLast("aggregator", new HttpObjectAggregator(10 * 1024 * 1024));
        pipeline.addLast("httpClientHandler", handler);
      }
    };
  }