Closed Bug 1157283 Opened 9 years ago Closed 9 years ago

Make synthesized redirections open the redirected channel in the child process

Categories

(Core :: Networking: HTTP, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox39 --- unaffected
firefox40 --- affected
firefox41 --- fixed

People

(Reporter: jdm, Assigned: jdm)

References

Details

Attachments

(2 files)

From bug 1122161 comment 11:
>OK.  Let HttpChannel parent tell the nsHttpChannel simply to not AsyncOpen the >new channel (rather throw it away) - this needs to be imlemented.  AsyncOpen on >the child will be called from CompleteRedirectSetup.  Unfortunatelly this will >need to be done on many places since we have mRedirectChannel->AsyncOpen spread >all over around.  Maybe do a cleanup patch first?
Comment on attachment 8601778 [details] [diff] [review]
Recreate IPC redirected HTTP channels as necessary after intercepting the request in the child

Review of attachment 8601778 [details] [diff] [review]:
-----------------------------------------------------------------

First, here are the tests that pass with these changes:
1) synthesizing a 302 to a real file
2) synthesizing a 302 to another synthesized response
3) synthesizing a 302 to #1
4) synthesizing a 302 to #2
5) fetching a 302 to #2, which yields a 404 since it should not be intercepted

With these changes, when a redirect is initiated in the parent from a synthesized response (eg. a synthesized 302) we intercept the redirected channel and suspend any further processing. The redirection completion notification in the child then destroys the IPC actor and performs a real AsyncOpen, which runs the usual SW interception - this will only end up recreating the IPC actor if a nontrivial response is synthesized (ie. one that requires processing in by the parent, such as a redirection). Additionally, these changes ensure that parent channels are either always forced to intercept (when a synthesized redirection occurred, or the parent is processing a synthesized response) or always forced to skip an interception check. This ensures that we follow the spec, which says that after a real network request occurs there must be no more opportunities to intercept redirections.
Attachment #8601778 - Flags: review?(honzab.moz)
Comment on attachment 8601778 [details] [diff] [review]
Recreate IPC redirected HTTP channels as necessary after intercepting the request in the child

Review of attachment 8601778 [details] [diff] [review]:
-----------------------------------------------------------------

Not tested locally.

r=honzab

::: netwerk/protocol/http/HttpChannelParent.h
@@ +205,5 @@
>  
> +  // Set if this channel should be intercepted before it sets up the HTTP transaction.
> +  bool mShouldIntercept;
> +  // Set if this channel should suspend on interception.
> +  bool mShouldSuspendIntercept;

when you are here, could you convert these to bit fields?

::: netwerk/protocol/http/nsIHttpChannelChild.idl
@@ +13,5 @@
>    void addCookiesToRequest();
>  
> +  // Mark this channel as requiring an interception; this will propagate
> +  // to the corresponding parent channel when a redirect occurs.
> +  void forceIntercepted();

change iid!
Attachment #8601778 - Flags: review?(honzab.moz) → review+
Josh, which versions of Firefox are affected by this?
Flags: needinfo?(josh)
Any version in which ServiceWorkers are enabled by default. That usually means 40+.
Flags: needinfo?(josh)
Ehsan flipped serviceworkers off again (on nightly builds too), so this doesn't affect anything right now unless users flip the pref
Running this through try showed that we leak the world for redirected, intercepted channels. This can be avoided by ensuring that the InterceptedChannelChrome is notified when the channel is torn down, but we can't do it any earlier because cancelling the channel will cause IPC notifications to be sent and confuse the child. This is the only solution I've been able to come up with.
Attachment #8611186 - Flags: review?(honzab.moz)
Comment on attachment 8611186 [details] [diff] [review]
Avoid leaking the world when tearing down an intercepted redirected channel

Review of attachment 8611186 [details] [diff] [review]:
-----------------------------------------------------------------

Sounds good to me.
Attachment #8611186 - Flags: review?(honzab.moz) → review+
https://hg.mozilla.org/mozilla-central/rev/b2c2577ac49c
Status: NEW → RESOLVED
Closed: 9 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: