Apache 在使用自定义 perl 模块时为所有请求提供 HTTP 404 错误

Apache give HTTP 404 error for all request when use custom perl module

我必须使用 apache 为我的项目创建 go 远程导入服务器,并且我尝试为处理来自用户的 go get 请求创建 perl 模块。

perl 模块(RemoteImport.pm)如下所示:

sub handler{
    my $r = shift;

    # check if request is from "go"
    return Apache2::Const::DECLINED if ($r->args() !~ /go\-get=1$/);

    // Code for provide necessary http body data for go get request and return OK.
}

Apache 配置:

PerlModule Gerrit::Go::RemoteImport
<Location />
    SetHandler perl-script
    PerlResponseHandler Gerrit::Go::RemoteImport
</Location>

go get 请求可以正常使用,但我发现另一个http 请求有问题,路径以“/”开头,Apache 没有继续正常处理请求并给出未找到的页面。

请帮我解决这个问题。

我从我的团队得到如下解决方案:

sub go_remote_import_response {
    my $r = shift;

    # Code for provide necessary http body data for go get request and return OK.
}

sub handler {
    my $r = shift;

    # check if request is from "go"
    return Apache2::Const::OK if ($r->args() !~ /go\-get=1$/);

    # change the response handler to our handler if the request are from "go"
    $r->handler('perl-script');
    $r->set_handlers(PerlResponseHandler => \&go_remote_import_response);

    return Apache2::Const::OK;
}