"2017-06-13T05:40:42Z" . . "915b8cfe966d681a106531b9a799c459" . "VirtuosoContentNegotiation" . . . . . . . "%VOSWARNING%\n\n\n---+ Transparent Content Negotiation in HTTP server\n\n---++ Purpose\n\nThe Transparent Content Negotiation (called TCN) is used is mehanism to provide best acceptable content by TCN cabaple user agents (UA).\nConsider a Web resource 'page' which has three variants: page.xml, page.html and page.txt all representing same data. The TCN capable UA can ask for 'page' content represented and indicate that XML format is preferred, then HTTP server then will transparently return page.xml. Most often UA understand different formats, e.g., XML, HTML, text etc., so in this case UA indicate order by specifying quality values for each type it understand. The server when receive request with multiple types acceptable will calculate quality for each variant and provide the best. In addition to returning content directly UA may ask server to provide a list of variants, then TCN capable client can choose the best for it. \nIn the above we give examples with MIME type of content, but this also apply to content language and content encoding negotiation.\nThe Virtuoso HTTP server TCN is based on experimental RFC2295, without \"Feature\" negotiation.\n\n---++ Table\nThe TCN variants are kept in a following SQL table:\n\n\ncreate table DB.DBA.HTTP_VARIANT_MAP (\n VM_ID integer identity, -- unique ID \n VM_RULELIST varchar, -- HTTP rule list name\n VM_URI varchar, -- The name of requested resource e.g. 'page'\n VM_VARIANT_URI varchar, -- The name of variant e.g. 'page.xml', 'page.de.html' etc.\n VM_QS float, -- Source quality, a float number 3 digit precision in 0.001-1.000 range\n VM_TYPE varchar, -- Content type of the variant e.g. text/xml\n VM_LANG varchar, -- Content language e.g. 'en', 'bg'. 'de' etc.\n VM_ENC varchar, -- Content encoding e.g. 'utf-8', 'ISO-8892' etc.\n VM_DESCRIPTION long varchar, -- a human readable description about variant e.g. 'Profile in RDF format'\n VM_ALGO int default 0, -- for future use\n primary key (VM_RULELIST, VM_URI, VM_VARIANT_URI))\ncreate unique index HTTP_VARIANT_MAP_ID on DB.DBA.HTTP_VARIANT_MAP (VM_ID)\n\n\n---++ Algorithm\n\nThe algorithm works as follows:\nIf a virtual directory (VD) has 'url_rewrite' option set then the Web server (WS) will \n\n 1. look in DB.DBA.HTTP_VARIANT_MAP for VM_RULELIST matching the one specified in 'url_rewrite' option\n 1. if present will loop over all variants for which VM_URI is equal to resource requested\n 1. for every variant it will calculate source quality based on VM_QS and source quality given by the UA\n 1. if best variant is found, it will add TCN HTTP headers and will pass the VM_VARIANT_URI to URL rewriter next\n 1. if UA asks for variant list, it will compose such and will return Alternates HTTP header with 300 response\n 1. if no URL rewrite rules exists, the WS will return content of expanded VM_VARIANT_URI \n\nNote: when UA asks for list then server return TCN header \"list\", when UA want negotiation then WS returns TCN header \"choice\", i.e., server may return list of variants or it may return best choice.\n\n---++ API\n\n---+++ Adding or updating a variant \n\nDB.DBA.HTTP_VARIANT_ADD (\n in rulelist_uri varchar, -- HTTP rule list name\n in uri varchar, -- The name of requested resource e.g. 'page'\n in variant_uri varchar, -- The name of variant e.g. 'page.xml', 'page.de.html' etc.\n in mime varchar, -- Content type of the variant e.g. text/xml\n in qs float := 1.0, -- Source quality, a float number 3 digit precision in 0.001-1.000 range\n in descrition varchar := null, -- a human readable description about variant e.g. 'Profile in RDF format'\n in lang varchar := null, -- Content language e.g. 'en', 'bg'. 'de' etc.\n in enc varchar := null -- Content encoding e.g. 'utf-8', 'ISO-8892' etc.\n )\n\n\n---+++ variant removal\n\nDB.DBA.HTTP_VARIANT_REMOVE (\n in rulelist_uri varchar, -- HTTP rule list name\n in uri varchar, -- The name of requested resource e.g. 'page'\n in variant_uri varchar := '%' -- Variant name filter \n )\n\n\n---++ Examples\n\n---+++ Prividing different content types\n\nIn this example we assume following files are uploaded in WedDAV server : \n * /DAV/page.xml - XML variant\n * /DAV/page.html - HTML variant\n * /DAV/page.txt - text variant\nThe above files are considered as containing same information by in different formats. \nWe add TCN rules & add a virtual directory: \n\nDB.DBA.HTTP_VARIANT_ADD ('http_rule_list_1', 'page', 'page.html', 'text/html', 0.900000, 'HTML variant');\nDB.DBA.HTTP_VARIANT_ADD ('http_rule_list_1', 'page', 'page.txt', 'text/plain', 0.500000, 'Text document');\nDB.DBA.HTTP_VARIANT_ADD ('http_rule_list_1', 'page', 'page.xml', 'text/xml', 1.000000, 'XML variant');\n\nDB.DBA.VHOST_DEFINE (lpath=>'/DAV', ppath=>'/DAV/', is_dav=>1, vsp_user=>'dba', opts=>vector ('url_rewrite', 'http_rule_list_1'));\n\n\nNow we can test the setup with an http client e.g. 'curl' program:\n\nHere UA tell server it better understand HTML and let server to perform TCN \n\n$ curl -i -H \"Accept: text/xml;q=0.3,text/html;q=1.0,text/plain;q=0.5,*/*;q=0.3\" -H \"Negotiate: *\" http://localhost:8890/DAV/page\nHTTP/1.1 200 OK\nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB\nConnection: Keep-Alive\nDate: Wed, 31 Oct 2007 15:43:18 GMT\nAccept-Ranges: bytes\nTCN: choice\nVary: negotiate,accept\nContent-Location: page.html\nContent-Type: text/html\nETag: \"14056a25c066a6e0a6e65889754a0602\"\nContent-Length: 49\n\n\n \n some html\n \n\n\n\nIn this case we change source quality values so UA tells it better understand XML\n\n$ curl -i -H \"Accept: text/xml,text/html;q=0.7,text/plain;q=0.5,*/*;q=0.3\" -H \"Negotiate: *\" http://localhost:8890/DAV/page\nHTTP/1.1 200 OK\nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB\nConnection: Keep-Alive\nDate: Wed, 31 Oct 2007 15:44:07 GMT\nAccept-Ranges: bytes\nTCN: choice\nVary: negotiate,accept\nContent-Location: page.xml\nContent-Type: text/xml\nETag: \"8b09f4b8e358fcb7fd1f0f8fa918973a\"\nContent-Length: 39\n\n\nsome xml\n\n\nAnd finally UA want to decide itslef, so he asks for list of variants, server will provide it and in addition will send an HTML body just in case so end user can decide himself if UA can't. \n\n$ curl -i -H \"Accept: text/xml,text/html;q=0.7,text/plain;q=0.5,*/*;q=0.3\" -H \"Negotiate: vlist\" http://localhost:8890/DAV/page\nHTTP/1.1 300 Multiple Choices\nServer: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu VDB\nConnection: close\nContent-Type: text/html; charset=ISO-8859-1\nDate: Wed, 31 Oct 2007 15:44:35 GMT\nAccept-Ranges: bytes\nTCN: list\nVary: negotiate,accept\nAlternates: {\"page.html\" 0.900000 {type text/html}}, {\"page.txt\" 0.500000 {type text/plain}}, {\"page.xml\" 1.000000 {type text/xml}}\nContent-Length: 368\n\n\n\n300 Multiple Choices\n\n

Multiple Choices

\nAvailable variants:\n\n
\n\nCategoryVirtuoso CategorySpec" . . . . . . "VirtuosoContentNegotiation" . "VirtuosoContentNegotiation" . "2017-06-13T05:40:42.435537"^^ . "2017-06-13T05:40:42Z" . . "2017-06-13T05:40:42.435537"^^ . . . .