Closed Bug 1336688 Opened 8 years ago Closed 8 years ago

[WebExtensions] Blocking any downloadable content

Categories

(WebExtensions :: Untriaged, defect)

53 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: antdlmr, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Steps to reproduce: Blocking any downloadable content in Google Chrome works: chrome.webRequest.onHeadersReceived.addListener( onHeadersReceived, { urls: [ "http://*/*", "https://*/*" ], types: [ "main_frame", "sub_frame", "image", "object", "xmlhttprequest", "other" ] }, ['blocking','responseHeaders']); function onHeadersReceived( res ) { ................... var result = [ { name: "Connection-token", value: "close" }, { name: "Content-Type", value: "multipart/related" }, { name: "Content-Length", value: "0" }]; return { responseHeaders: result }; <=== BUT IT DOES NOT WORK IN FIREFOX! } }; Actual results: How can I make the blocking of downloading?
Error setting response header content-length: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIHttpChannel.setResponseHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: resource://gre/modules/WebRequest.jsm :: setHeader :: line 214" data: no]
Component: Untriaged → WebExtensions: Untriaged
Product: Core → Toolkit
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Sorry, but the reference bug 1304331 has not led me to the solution of problem. I need to cancel the request. I have a solution for Google Chrome, but it does not work for Firefox. I hoped the Content-Length: 0 for http header rejected the request but any value of this field makes error. May be there is another solution? Thank you for help!
Status: RESOLVED → UNCONFIRMED
Resolution: DUPLICATE → ---
We don't allow changing the Content-Length header, for a variety of reasons. If you want to cancel the request, please just cancel it.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → WORKSFORME
Yes, my main purpose is to cancel the downloading. How can I do it? I can not find a way to do it in onHeadersReceived method.
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago8 years ago
Resolution: --- → WORKSFORME
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.