0

i am new to plugin development. I was told to use Firebreath, for developing npapi plugins, and it turned out to be very easy. Now, i wish to access the http response header of the response passed on to plugin. But i couldn't figure out a way as their is scarce doc available for firebreath. In NPAPI tutorials, they use npstream, but i can't figure out how to use this structure in firebreath. Any help will be highly appreciated.

Update:

void tPlugin::handleUnsolicitedStream(FB::BrowserStreamRequest& req)
{ 
 const FB::PluginEventSinkPtr sinkPtr;
 req.setEventSink(sinkPtr);
 responseHeaders = req.headers;
 FB::HeaderMap::const_iterator it = responseHeaders.begin();
 str = (*it).first + " : " + (*it).second;                   // str is a class variable
 FB::DOM::WindowPtr window = m_host->getDOMWindow();
 window->alert(str);
 str = "hello";
 window->alert(fname);
}

None of the alert box appears!

void tPlugin::onPluginReady()
{
   FB::DOM::WindowPtr window = m_host->getDOMWindow();
   window->alert(str);
}

An empty alert box appears!

adnan kamili
  • 8,967
  • 7
  • 65
  • 125

1 Answers1

1

If you read the source for the BrowserStreamRequest object that you are using, or even better if you read the source for where it is created, you will find that there is a headers variable on the object.

FB::HeaderMap headers;

FB::HeaderMap, of course, is defined in SimpleStreamHelper.h:

typedef std::multimap<std::string, std::string> HeaderMap;

And, to clarify, there is plenty of documentation for FireBreath; just not a lot for this particular feature, which has only been in the tree for about a month.

Edit: From past conversations I'm pretty sure you're already handling this, but the stream created by the browser is given to you with the BrowserStreamRequest object passed into the handleUnsolicitedStream method on your plugin object; this method isn't overridden by your plugin by default in the fbgen template, but you can add it.

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • You ask for the location of the headers that come from the response; they are put into the BrowserStreamRequest object which is created apon creation of the stream (in NPP_NewStream) – taxilian Nov 06 '12 at 03:04
  • This is where I'm confused, because from past conversations with you I thought you were already handling unsolicited streams, but I have updated my answer to include that info. – taxilian Nov 06 '12 at 16:28
  • Perhaps you don't understand my answer; I'm not talking about when you create an http request. I'm talking about the case where the browser receives a response containing a mime-type and the plugin is invoked. When you want the headers of that same response, the handleUnsolicitedStream method is called. There is a public property of type FB::HeaderMap on that FB::BrowserStreamRequest object that has the headers that you are looking for in it. it isn't a method! it's just a public property. Go look at the code. Also try a debugger. I don't know how else I can explain the same thing. – taxilian Nov 07 '12 at 15:45
  • Sorry. You're welcome to attach a debugger and try to verify this, but most likely if that's the case then the browser simply isn't providing any header information. – taxilian Dec 24 '12 at 00:28
  • If you'll follow the thread, you'll see the jira ticket referenced is http://jira.firebreath.org/browse/FIREBREATH-210 which is resolved. (yes, it is fixed) – taxilian Dec 24 '12 at 07:15
  • response headers are doing fine, can i access request header which invoked the response header? – adnan kamili Jan 06 '13 at 10:54
  • There is no way that I know of to access the request header, no – taxilian Jan 06 '13 at 20:20