代码之家  ›  专栏  ›  技术社区  ›  aidan

使用apache和mod_perl为动态生成的图像提供服务的正确方法是什么?

  •  3
  • aidan  · 技术社区  · 15 年前

    我有一个Apache2/mod_Perl2系统正在运行。

    我在用 GD 要动态创建图像,然后按如下方式打印:

    $r->content_type('image/png');
    binmode STDOUT;
    print $im->png;
    

    但这是正确的方法吗 mod_perl2 ?

    (忽略我正在动态生成图像而不是缓存它等事实…)

    1 回复  |  直到 15 年前
        1
  •  6
  •   friedo    15 年前

    在mod_perl2下,您不应该将内容直接打印到 STDOUT . 相反,使用

    use Apache2::Const 'OK';
    
    $r->content_type( 'image/png' );
    $r->print( $im->png );
    
    return OK;