Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-2360

Add qsappend flag to rewrite() handler

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • 2.4.0.Final
    • None
    • Predicate Language
    • None

      It is common, and very useful in other rewrite engines to have a flag similar to mod_rewrites `qsappend`, which merges the query strings of the rewritten URL instead of replacing the old query string.  Appending query strings is already a pain due to these bugs:

      https://issues.redhat.com/browse/UNDERTOW-2358

      https://issues.redhat.com/browse/UNDERTOW-2359

      In fact, the ONLY way to actually merge the actual query strings while accounting for an empty initial query string is to dig through the Undertow source and find the undocumented `%{BARE_QUERY_STRING}` placeholder!

      I'm recommending a pragmatic approach to improve the rewrite() handler directly by adding an optional parameter called `qsappend` .

      • When false (default), the original query string will be discarded IF the rewrite includes its own query string
      • When true, the new and old query strings will be merged and both the query parameters and the query string in the exchange will be updated to reflect this.
      rewrite( value='/new/path?baz=bum', qsappend=true ) 

      Also consider adding a `qsdiscard` flag as well to borrow one more things from mod_cfml which would discard the original query string.  This would be handy if you want to discard the old query string but not specify a new one.  

              flaviarnn Flavia Rainone
              bdw429s Brad Wood
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: