Add schema for http_rewrite filter
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 Jul 2013 12:26:04 +0000 (14:26 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 19 Jul 2013 12:42:51 +0000 (14:42 +0200)
etc/Makefile.am
etc/config-rewrite.xml [new file with mode: 0644]
xml/schema/Makefile.am
xml/schema/filter_http_rewrite.rnc [new file with mode: 0644]
xml/schema/metaproxy.rnc

index 50e4d4c..5dbb9fb 100644 (file)
@@ -23,6 +23,7 @@ xmlconfig = $(srcdir)/config-bytarget.xml \
     $(srcdir)/config-solr.xml \
     $(srcdir)/config-zoom.xml \
     $(srcdir)/config-proxy.xml \
+    $(srcdir)/config-rewrite.xml \
     $(srcdir)/retrieval-info.xml
 
 config = example.simple-auth example.target-auth pqf2pqf.xsl explain.xml \
diff --git a/etc/config-rewrite.xml b/etc/config-rewrite.xml
new file mode 100644 (file)
index 0000000..4ad9ff8
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version='1.0'?>
+<metaproxy xmlns="http://indexdata.com/metaproxy" version="1.0">
+  <start route="start"/>
+  <routes>
+    <route id="start">
+<filter type='http_rewrite'>
+  <request verbose="1">
+    <rule name="null"/>
+    <rule name="url">
+      <rewrite
+         from='(?&lt;proto>https?://)(?&lt;pxhost>[^ /?#]+)/(?&lt;pxpath>[^ /]+)/(?&lt;host>[^ /]+)(?&lt;path>[^ ]*)'
+         to='${proto}${host}${path}' />
+      <rewrite from='(?:Host: )(.*)' to='Host: ${host}' />
+    </rule>
+    <content type="headers">
+      <within header="link" rule="null"/>
+      <within reqline="1" rule="url"/>
+    </content>
+  </request>
+  <response verbose="1">
+    <rule name="null"/>
+    <rule name="url">
+      <rewrite from='foo' to='bar'/>
+      <rewrite from='^cx' to='cy'/>
+      <rewrite
+         from='(?&lt;proto>https?://)(?&lt;host>[^/?# &quot;&apos;>]+)/(?&lt;path>[^  &quot;&apos;>]+)'
+         to='${proto}${pxhost}/${pxpath}/${host}/${path}' />
+    </rule>
+    <content type="headers">
+      <within header="link" rule="url"/>
+    </content>
+    <content type="html" mime="text/xml|text/html">
+      <within tag="body" attr="background" rule="null"/>
+      <within tag="script" attr="#text" type="quoted-literal" rule="url"/>
+      <within tag="style" attr="#text" rule="url"/>
+      <within attr="href,src" rule="url"/>
+      <within attr="onclick" type="quoted-literal" rule="url"/>
+    </content>
+    <content type="quoted-literal" mime=".*javascript">
+      <within rule="url"/>
+    </content>
+  </response>
+</filter>
+    </route>
+  </routes>
+</metaproxy>
index a605b48..c62f1b9 100644 (file)
@@ -12,6 +12,8 @@ filter_cql_rpn.rnc \
 filter_frontend_net.rnc \
 filter_http_client.rnc \
 filter_http_file.rnc \
+filter_http_rewrite.rnc \
+filter_http_rewrite1.rnc \
 filter_limit.rnc \
 filter_load_balance.rnc \
 filter_log.rnc \
diff --git a/xml/schema/filter_http_rewrite.rnc b/xml/schema/filter_http_rewrite.rnc
new file mode 100644 (file)
index 0000000..99b1214
--- /dev/null
@@ -0,0 +1,44 @@
+# Metaproxy XML config file schema
+
+namespace mp = "http://indexdata.com/metaproxy"
+
+rewrite = element mp:rewrite {
+  attribute from { xsd:string },
+  attribute to { xsd:string }
+}
+
+rule = element mp:rule {
+  attribute name { xsd:string },
+  rewrite*
+}
+
+within = element mp:within {
+  attribute tag { xsd:string }?,
+  attribute attr { xsd:string }?,
+  attribute type { xsd:string }?,
+  attribute header { xsd:string }?,
+  attribute reqline { xsd:string }?,
+  attribute rule { xsd:string }
+}
+
+content = element mp:content {
+  attribute type { xsd:string },
+  attribute mime { xsd:string }?,
+  within*
+}
+
+section = (rule | content)*
+
+filter_http_rewrite =
+  attribute type { "http_rewrite" },
+  attribute id { xsd:NCName }?,
+  attribute name { xsd:NCName }?,
+  element mp:request {
+    attribute verbose { xsd:string },
+    section
+  }?,
+  element mp:response {
+    attribute verbose { xsd:string },
+    section
+  }?
+
index 1562fb2..4d9263e 100644 (file)
@@ -30,6 +30,7 @@ include "filter_cql_rpn.rnc"
 include "filter_frontend_net.rnc"
 include "filter_http_client.rnc"
 include "filter_http_file.rnc"
+include "filter_http_rewrite.rnc"
 include "filter_http_rewrite1.rnc"
 include "filter_limit.rnc"
 include "filter_load_balance.rnc"
@@ -82,6 +83,7 @@ filter =
     | filter_frontend_net
     | filter_http_client
     | filter_http_file
+    | filter_http_rewrite
     | filter_http_rewrite1
     | filter_limit
     | filter_load_balance