Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist original request object in Spiderable variable #1

Closed
lucazulian opened this issue Mar 31, 2015 · 1 comment
Closed

Persist original request object in Spiderable variable #1

lucazulian opened this issue Mar 31, 2015 · 1 comment
Assignees

Comments

@lucazulian
Copy link

I'm using Spiderable with Phantomjs and I need the original request object in order to fetch header properties (in my case I need accept-language header). We could achieve this and allow Meteor to use that property by modifying the spiderable_server.js file in this way:

WebApp.connectHandlers.use(function (req, res, next) {
  // _escaped_fragment_ comes from Google's AJAX crawling spec:
  // https://developers.google.com/webmasters/ajax-crawling/docs/specification
  if (/\?.*_escaped_fragment_=/.test(req.url) ||
      _.any(Spiderable.userAgentRegExps, function (re) {
        return re.test(req.headers['user-agent']); })) {

    Spiderable.originalReq = req; // this is the new property

    var url = Spiderable._urlForPhantom(Meteor.absoluteUrl(), req.url);

In this way I can use Spiderable.originalReq to read from Meteor the original request headers.
Did that all make sense? :)
Let me know if you want me to submit a pull request.

@jazeee
Copy link
Collaborator

jazeee commented Mar 31, 2015

Seems reasonable. I'll add the following line as suggested.
Spiderable.originalRequest = req;

Note, I prefer fully spelled out variables (originalRequest), so that's what I used.
Also, I updated the Readme.md to match.

It is published to meteor as v1.1.3
Update using meteor update jazeee:spiderable-longer-timeout

@jazeee jazeee self-assigned this Mar 31, 2015
@jazeee jazeee closed this as completed Mar 31, 2015
jazeee pushed a commit that referenced this issue Jul 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants