[go: nahoru, domu]

Skip to content

Commit

Permalink
fs: handler tuning (cookies, cache validation)
Browse files Browse the repository at this point in the history
- no-cookies for `/ip(f|n)s/`
- no-cache-validation for `/ipfs/`
- closes #72
  • Loading branch information
lidel committed Feb 18, 2016
1 parent 7a46ecd commit c75a05d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 54 deletions.
1 change: 0 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const parent = require('sdk/remote/parent')

exports.main = function (options, callbacks) { // eslint-disable-line no-unused-vars
require('./redirects.js')
require('./request-fix.js')
require('./peer-watch.js')
protocols.register()
parent.remoteRequire('./child-main.js', module)
Expand Down
16 changes: 10 additions & 6 deletions lib/protocols.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,18 @@ CommonProtocolHandler.prototype = Object.freeze({
if (gw.fsUris && this.scheme === FS_SCHEME) {
channel.originalURI = aURI
channel.loadFlags &= ~Ci.nsIChannel.LOAD_REPLACE
// channel.loadFlags |= Ci.nsIChannel.LOAD_ANONYMOUS
}

channel.loadInfo = loadInfo

This comment has been minimized.

Copy link
@the8472

the8472 Feb 18, 2016

Contributor

You should keep that, I've seen cases in the debugger where loadInfo was null after http channel creation and newChannel2 basically promises to return a channel with the provided loadinfo set.

This comment has been minimized.

Copy link
@the8472

the8472 Feb 18, 2016

Contributor

Hrrm, thinking about it, that might have been due to newChannel delegating to newChannel2.

I guess you can keep it as is for now. It can be added back later if any problem occurs.

// Cookies make no sense in the ipfs context
// unless we have Suborigin header support.
// Until https://git.io/vgAMj is resolved
// we don't want to carry different gateway cookies into the page
channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS

channel.QueryInterface(Ci.nsIWritablePropertyBag)
channel.QueryInterface(Ci.nsIWritablePropertyBag2)
channel.setPropertyAsAString('ipfs-uri', aURI.spec)
if (isIPFS.ipfsPath(aURI.path)) {
// no revalidation for /ipfs/ from cache, those are immutable
channel.loadFlags |= Ci.nsIRequest.VALIDATE_NEVER
}
}

// console.info('newChannel routed to HTTP gateway: ' + channel.URI.spec)
return channel
Expand Down
47 changes: 0 additions & 47 deletions lib/request-fix.js

This file was deleted.

0 comments on commit c75a05d

Please sign in to comment.