Menu

#1430 add Filter on content-type

closed
5
2011-07-17
2011-07-03
Anonymous
No

Hello. How i can add some filters on certain content-type or other header?
for example only for Content-Type:text/html
Thanks

Discussion

  • Fabian Keil

    Fabian Keil - 2011-07-03

    You first use a server-header tagger to tag responses and then use the created tags to enable the filters you want to use.

    Privoxy even comes with a content-type tagger you could use for this, but if you are only looking for a certain mime-type, I'd personally prefer to write a dedicated tagger anyway, and only tag those responses that should be filtered.

    There are a couple of taggers in default.filter that you could use as example. default.action contains two sections that are enabled based on tags.

    You also might want to have a look at the documentation at:
    http://config.privoxy.org/user-manual/actions-file.html#SERVER-HEADER-TAGGER
    http://config.privoxy.org/user-manual/actions-file.html#CLIENT-HEADER-TAGGER

    Note that if you want to filter responses with content-types Privoxy doesn't filter by default, you'll have to additionally use the somewhat poorly named force-text-mode action to force Privoxy to apply the filters anyway:
    http://config.privoxy.org/user-manual/actions-file.html#FORCE-TEXT-MODE

     
  • Fabian Keil

    Fabian Keil - 2011-07-03
    • assigned_to: nobody --> fabiankeil
    • status: open --> pending
     
  • Anonymous

    Anonymous - 2011-07-03

    Ok. Thanks a lot. I want to use it with text / html.
    I must
    Tag respons with SERVER-HEADER-TAGGER
    and add filter to this tag
    Right?

     
  • Fabian Keil

    Fabian Keil - 2011-07-03

    Yes, this should work.

    Can you describe why you only want to enable the filter for text/html, though?

    Even if a filter is only supposed to filter HTML it usually doesn't hurt to enable it without manually looking at the content-type, anyway.

    Privoxy itself checks the Content-Type header, too, and will not execute the filter for non-text data provided its declared properly (and you don't force filtering with the force-text-mode action).

    Therefore usually tagging based on the Content-Type header isn't necessary, unless you want to enable the filter for mime types Privoxy doesn't consider filterable, or if you know for a fact that your filter will break things in case of some mime types Privoxy does filter by default.

    The latter case should be rather uncommon.

     
  • Anonymous

    Anonymous - 2011-07-03

    I want to use it because we have some problems with Youtube on iOS
    i have simple filter. And if i try to watch some video, in native app i have error "server is not configured properly". And mobile version(in safari) don't download video. I try to remove filter for youtube

    { +filter{my_filter}}
    / # Match all URLs

    {-filter{my_filter}}
    .youtube.

    and mobile version works great. But native app raises error (may be native app use different domain)

    And i think that error can be fixed filtering only text/html. Becouse we need filter only html pages.

     
  • Fabian Keil

    Fabian Keil - 2011-07-03

    If you aren't sure where the breakage is happening yet, I'd suggest you increase the debug level and check the logfile. Once you know why the problem is happening, solving the problem by adjusting the filter may be an option.

    In general I agree that this is a case where tagging text/html may make sense, though.

     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending --> closed
     

Log in to post a comment.