rejetto forum

Macros matching only a Content-Type

0 Members and 1 Guest are viewing this topic.

Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 859
  • Status: On hiatus       (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
After reading this post, I have a hypothetical question about macros. I already know how to make a macro that match a file extension in a URL (for example: {.match|*.jpg;*.gif|%url%.}), but I don't know how to ONLY match a 'Content-Type' found in a header. (I've read the Wiki, but found nothing relevant to my question)

I've tried with the following, without success:

Code: [Select]
[pre-filter-request]
{.if|{.match|*text/html*|{.header|Content-Type.}.}|{:
{.add to log|Web page was served.}
{.add header|Expires: 1.}
:}.}

My idea is ONLY match requests, with any of these headers:

Content-Type:"text/html; charset=utf-8"

and/or

Content-Type:"text/html"

Do you know how to ONLY match a header, with a 'Content-Type' of 'text/html'?. I do NOT want to match files with *.html or *.htm extension (I repeat: I do NOT want to filter or match files by extension). The type of 'Content-Type' was only an example, but it can be any other type.

What am I doing wrong?... :-\
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 859
  • Status: On hiatus       (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
I've also tried this (without success, since it doesn't work as expected):

Code: [Select]
[pre-filter-request]
{.add header|Expires: 0|if=
   {.and
      |{.match|*text/html*|{.header|Content-Type.}.}
   .}   
.}

Neither this works...

Code: [Select]
[pre-filter-request]
{.if|
   {.match|*html*|{.header|Content-Type.}.}|
{:
          {.add to log|Web site served 2.}
  {.add header|Expires: 2.}
:}
   .}
.}

This is puzzling, but after many crazy tests, I think we got a bug...

See, this example SEEMS to working (but it's working bad, see at the end):

Code: [Select]
[+request]
{.disconnection reason|It seems to work since all UA have Mozilla|if=
   {.and
      |{.match|*Mozilla*|{.header|User-Agent.}.}
   .}   
.}

But this another example should NOT work (since 'Content-Type' can never be 'Mozilla'):

Code: [Select]
[+request]
{.disconnection reason|Whoa there, something is wrong here|if=
   {.and
      |{.match|*Mozilla*|{.header|Content-Type.}.}
   .}   
.}

And another crazy example...

Code: [Select]
[+request]
{.disconnection reason|It should work since there is no mysterious browser|if=
   {.and
      |{.match|*mysterious*|{.header|User-Agent.}.}
   .}   
.}

» Result: Something weird is happening here (or I'm doing all wrong)... :o

*** Since I already know Rejetto is not actively working on v2.4x (and I don't expect him to do it), I'm open to receive the modifications needed in the source code to fix this (since I can compile HFS by myself). ***
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.