gpt4 book ai didi

firefox - NPP_NewStream : seekable set to 0 (false) for local file

转载 作者:行者123 更新时间:2023-12-01 03:48:45 25 4
gpt4 key购买 nike

我正在尝试实现一个具有流媒体功能的 NPAPI 插件(NP_SEEK+ NPN_RequestRead)。无论我尝试什么, bool NPBool seekable 始终设置为 0(假)。

我正在从本地文件的命令行启动 firefox(Debian 上的 iceweasel):

$ iceweasel test1.html

如果我将 gdb 附加到 npapi 插件,我会看到:
(gdb) 
#2 0x00007f7e9da54e14 in mozilla::plugins::BrowserStreamChild::StreamConstructed (this=0x7f7e925cf310, mimeType=..., seekable=<optimized out>, stype=<optimized out>)
at /tmp/buildd/iceweasel-24.6.0esr/dom/plugins/ipc/BrowserStreamChild.cpp:62
62 &mStream, seekable, stype);
(gdb)
#3 0x00007f7e9da5688e in mozilla::plugins::PluginInstanceChild::AnswerPBrowserStreamConstructor (this=<optimized out>, aActor=<optimized out>, url=...,
length=<optimized out>, lastmodified=<optimized out>, notifyData=<optimized out>, headers=..., mimeType=..., seekable=@0x7fff25ed51df: false, rv=0x7fff25ed51e0,
stype=0x7fff25ed51e2) at /tmp/buildd/iceweasel-24.6.0esr/dom/plugins/ipc/PluginInstanceChild.cpp:2285
2285 ->StreamConstructed(mimeType, seekable, stype);
(gdb) p seekable
$1 = (const bool &) @0x7fff25ed51df: false
(gdb) up
#4 0x00007f7e9da8f77f in mozilla::plugins::PPluginInstanceChild::OnCallReceived (this=0x7f7e925f2c00, __msg=..., __reply=@0x7fff25ed5470: 0x0)
at /tmp/buildd/iceweasel-24.6.0esr/build-xulrunner/ipc/ipdl/PPluginInstanceChild.cpp:2479
warning: Source file is more recent than executable.
2479 if ((!(AnswerPBrowserStreamConstructor(actor, url, length, lastmodified, notifyData, headers, mimeType, seekable, (&(rv)), (&(stype)))))) {
(gdb) list -
2469 if ((!(actor))) {
2470 return MsgValueError;
2471 }
2472 (actor)->mId = RegisterID(actor, (__handle).mId);
2473 (actor)->mManager = this;
2474 (actor)->mChannel = mChannel;
2475 (mManagedPBrowserStreamChild).InsertElementSorted(actor);
2476 (actor)->mState = mozilla::plugins::PBrowserStream::__Start;
2477
2478 int32_t __id = mId;
(gdb) list -
2459 FatalError("Error deserializing 'bool'");
2460 return MsgValueError;
2461 }
2462 (__msg).EndRead(__iter);
2463 if ((!(PPluginInstance::Transition(mState, Trigger(Trigger::Send, PPluginInstance::Msg_PBrowserStreamConstructor__ID), (&(mState)))))) {
2464 NS_WARNING("bad state transition!");
2465 }
2466 NPError rv;
2467 uint16_t stype;
2468 actor = AllocPBrowserStream(url, length, lastmodified, notifyData, headers, mimeType, seekable, (&(rv)), (&(stype)));
(gdb) list -
2449 }
2450 if ((!(Read((&(headers)), (&(__msg)), (&(__iter)))))) {
2451 FatalError("Error deserializing 'nsCString'");
2452 return MsgValueError;
2453 }
2454 if ((!(Read((&(mimeType)), (&(__msg)), (&(__iter)))))) {
2455 FatalError("Error deserializing 'nsCString'");
2456 return MsgValueError;
2457 }
2458 if ((!(Read((&(seekable)), (&(__msg)), (&(__iter)))))) {
(gdb) up
#5 0x00007f7e9da868f0 in mozilla::plugins::PPluginModuleChild::OnCallReceived (this=<optimized out>, __msg=..., __reply=@0x7fff25ed5470: 0x0)
at /tmp/buildd/iceweasel-24.6.0esr/build-xulrunner/ipc/ipdl/PPluginModuleChild.cpp:1023
warning: Source file is more recent than executable.
1023 return (__routed)->OnCallReceived(__msg, __reply);
(gdb) list -
1013 PPluginModuleChild::OnCallReceived(
1014 const Message& __msg,
1015 Message*& __reply)
1016 {
1017 int32_t __route = (__msg).routing_id();
1018 if ((MSG_ROUTING_CONTROL) != (__route)) {
1019 ChannelListener* __routed = Lookup(__route);
1020 if ((!(__routed))) {
1021 return MsgRouteError;
1022 }
(gdb) bt

如果我将 test1.html 复制到 /var/www ,然后指向 http://localhost/test1.html 一切都按预期工作。

然而 documentation 提到
seekable
Boolean indicating whether the stream is seekable:
true: Seekable. Stream supports random access through calls to NPN_RequestRead (for example, local files or HTTP servers that support byte-range requests).

最佳答案

文档完全是谎言。

  • seekableNPP_NewStream 的调用中的标志
  • 源自 OnStartBinding
  • 调用 nsPluginStreamListenerPeer::IsSeekable
  • 只返回 nsPluginStreamListenerPeer::mSeekable .
  • 唯一一次mSeekable曾经设置过true是什么时候(source)
  • 流是 http (https, spdy)
  • http 响应没有 Content-Encoding
  • http 响应提供 Content-Length .
  • http 响应有 Accept-Ranges: bytes (不支持省略标题)
  • 对于所有其他流类型(包括 file:// )和不符合要求的 http 流,seekable因此标志总是false .

  • 此外, NPN_RequestReadonly implemented for http streams , 但实际上并不关心 seekable而且实际上并不检查服务器是否返回 206 .

    结论

    您只能使用 NP_SEEK使用 http (https, spdy) 流式传输。这就是为什么东西从 http://localhost 开始工作的原因,但不是来自本地文件( file:// )。

    关于firefox - NPP_NewStream : seekable set to 0 (false) for local file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24651948/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com