如何手动创建 Apache 请求对象?
是否有一个好的 API 允许某人创建 Apache
类?
类本身似乎缺少构造函数;概要并没有多大帮助。我怀疑它是通过 sublcas 以某种方式完成的,例如 Apache::Request?
上下文是我正在尝试为使用 Embperl 的 $HTML::Embperl::req_rec
变量(更具体地说,调用包含在 它)。经检查,该变量包含一个带有 ref($req_rec) eq 'Apache'
的对象。
注意:我特别询问如何构建一个真实的(尽管不一定功能齐全)对象。 不嘲笑它(我显然可以轻松做到这一点,并且可能最终会这样做)。
Is there a good API that would allow someone to create an object of Apache
class?
The class itself seems to lack a constructor; and synopsis wasn't very helpful. My suspicion is that it's somehow done via sublcass, e.g. Apache::Request
?
The context is I'm trying to write a test for a module which uses Embperl's $HTML::Embperl::req_rec
variable (more specifically, calls the uri()
method on an object contained in it). The variable, upon examination, contains an object with ref($req_rec) eq 'Apache'
.
NOTE: I'm specifically asking about constructing a REAL (though not necessarily fully functional) object. NOT mocking it (which I obviously easily can do and probably will end up doing anyway).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不相信您可以创建
Apache::Request
对象。目的是让 mod_perl 运行时为您创建它们——它们在内部绑定到 Apache 进程内的结构,而这些结构可能无法从 perl 创建。如果您仅使用该对象执行相对简单的操作,则可以使用
CGI
对象来完成相同的工作。但是,如果发生任何复杂的情况,除了模拟对象或在实时 Apache 实例中进行测试之外,可能没有其他选择。I don't believe you can create
Apache::Request
objects, period. The intent is for them to be created for you by the mod_perl runtime -- they're internally bound to structures within the Apache process which may not be possible to create from perl.If you're only doing relatively simple things with the object, you may be able to get a
CGI
object to do the same job. If anything complex is going on, though, there's probably little alternative besides mocking the object or testing within a live Apache instance.