Chrome's HEAD request wipes flash messages #20

Closed
msaspence opened this Issue May 25, 2011 · 6 comments

3 participants

@msaspence

I'm running apache, and php in fcgid on a locahost (not sure if this is relavent, but there you go)

Chrome is sending a HEAD request immediately after each GET or POST

As flash messages are destroyed on the next request the HEAD request is wiping them before the next GET or POST

the flow goes a little like this

GET /step1:
flash("message","hello");

HEAD /step1
flash_sweep(); // destroys flash message

GET /step2
flash_now("message") // returns null

I can't do a pull request as I've quite substantially forked other parts, but the fix I've implement is in the stop_and_exit definition changing:

if($flash_sweep) flash_sweep();

to:

if($flash_sweep && !request_is_head()) flash_sweep();
@atdiehm atdiehm added a commit to atdiehm/limonade that referenced this issue May 26, 2011
@atdiehm atdiehm Issue #20: Implementing fix suggested by @msaspence to remedy an issu…
…e with Chrome and flash messages
f9a6b17
@atdiehm

@msaspence, I had a clean fork, so I made this update, and appended my current hanging pull request to contain it.

@msaspence

cool thanks

@msaspence msaspence closed this May 26, 2011
@msaspence msaspence reopened this May 26, 2011
@sofadesign
Owner

But why your chrome browser is sending a HEAD request after each GET and POST ? This is a strange and specific behaviour. Which version of Chrome do you use ? Is there an extension that could explain that double request ?

@msaspence

looks like its caused by webug extension

https://chrome.google.com/webstore/detail/cjbeipenlpoeifpkjhgakejmikdhlhcj

whilst this may be a fringe case it seems to make sense to not sweep flash messages for head requests

@sofadesign
Owner

You're right. I wanted to know where this HEAD request comes from before writing tests.

@sofadesign sofadesign pushed a commit that referenced this issue May 30, 2011
Fabrice Luraine Prevents flash sweep for HEAD requests like suggested by @msaspence i…
…n issue #20.

Can be useful when using browser extensions like webug in Chrome which
send a HEAD request after each GET or POST request.
7316f0f
@sofadesign
Owner

I've pushed the fix with tests on the master branch.

@sofadesign sofadesign closed this May 30, 2011
@CBeerta CBeerta added a commit that referenced this issue May 30, 2011
Fabrice Luraine Prevents flash sweep for HEAD requests like suggested by @msaspence i…
…n issue #20.

Can be useful when using browser extensions like webug in Chrome which
send a HEAD request after each GET or POST request.
491bbaf
@kematzy kematzy added a commit to kematzy/limonade that referenced this issue Dec 29, 2011
@kematzy kematzy Merge branch 'refs/heads/kematzy' into with-settings-output
* refs/heads/kematzy: (30 commits)
  Added new option() related functionality
  Typo fixes
  Amended private version with some extra goodies thrown in
  Reorder initial configuration settings in run function
  Rename _lim_header to send_header. Rename inspect_header to before_sending_header.
  Add a way to manage fallbacks for not implemented functions. Raise warning if try to use json_encode() when it's not available. PHP 5 < PHP 5.2.0 doesn't provide json functions natively.
  Fix a small PHP notice in a test (undefined index…)
  Fix PHP Parse error when running tests on PHP5.3.0 < : use eval to declare a lambda function.
  Fix warning in tests on PHP5.2.3 < . Avoid test for call_if_exists with static class method call.
  Fix fatal error if memory_get_usage() isn't available. Now benchmark() only return execution time in this case.
  Remove from the README file the link to the public API because it's no longer maintened.
  Add requirements in README [#50 state:resolved]
  Prevents flash sweep for HEAD requests like suggested by @msaspence in issue #20.
  Fix backward compatibilty function limonade_htmlspecialchars_decode. Now supports &#39; entities
  Add a way to manage fallbacks for not implemented functions. Raise warning if try to use json_encode() when it's not available. PHP 5 < PHP 5.2.0 doesn't provide json functions natively.
  Fix a small PHP notice in a test (undefined index…)
  Fix PHP Parse error when running tests on PHP5.3.0 < : use eval to declare a lambda function.
  Fix warning in tests on PHP5.2.3 < . Avoid test for call_if_exists with static class method call.
  Fix fatal error if memory_get_usage() isn't available. Now benchmark() only return execution time in this case.
  Remove from the README file the link to the public API because it's no longer maintened.
  ...

Conflicts:
	lib/limonade.php
8e1f5a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment