{"action":"closed","issue":{"url":"https://api.github.com/repos/hapijs/hapi/issues/2778","labels_url":"https://api.github.com/repos/hapijs/hapi/issues/2778/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/hapi/issues/2778/comments","events_url":"https://api.github.com/repos/hapijs/hapi/issues/2778/events","html_url":"https://github.com/hapijs/hapi/issues/2778","id":107742311,"number":2778,"title":"XML POST with Faketoe onRequest hack","user":{"login":"DerykHopley","id":3304470,"avatar_url":"https://avatars.githubusercontent.com/u/3304470?v=3","gravatar_id":"","url":"https://api.github.com/users/DerykHopley","html_url":"https://github.com/DerykHopley","followers_url":"https://api.github.com/users/DerykHopley/followers","following_url":"https://api.github.com/users/DerykHopley/following{/other_user}","gists_url":"https://api.github.com/users/DerykHopley/gists{/gist_id}","starred_url":"https://api.github.com/users/DerykHopley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DerykHopley/subscriptions","organizations_url":"https://api.github.com/users/DerykHopley/orgs","repos_url":"https://api.github.com/users/DerykHopley/repos","events_url":"https://api.github.com/users/DerykHopley/events{/privacy}","received_events_url":"https://api.github.com/users/DerykHopley/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/hapi/labels/question","name":"question","color":"d4c5f9"}],"state":"closed","locked":false,"assignee":{"login":"hueniverse","id":56631,"avatar_url":"https://avatars.githubusercontent.com/u/56631?v=3","gravatar_id":"","url":"https://api.github.com/users/hueniverse","html_url":"https://github.com/hueniverse","followers_url":"https://api.github.com/users/hueniverse/followers","following_url":"https://api.github.com/users/hueniverse/following{/other_user}","gists_url":"https://api.github.com/users/hueniverse/gists{/gist_id}","starred_url":"https://api.github.com/users/hueniverse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hueniverse/subscriptions","organizations_url":"https://api.github.com/users/hueniverse/orgs","repos_url":"https://api.github.com/users/hueniverse/repos","events_url":"https://api.github.com/users/hueniverse/events{/privacy}","received_events_url":"https://api.github.com/users/hueniverse/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-09-22T15:42:53Z","updated_at":"2015-09-22T16:24:45Z","closed_at":"2015-09-22T16:24:44Z","body":"Hi,\r\n\r\nSo I've been trying to get my hapi server to accept XML and convert it to JSON then use my main route validation etc. \r\nAfter much googling and head bashing I got a working redirect hack.\r\nSo I use onRequest to redirect to the /xml2json route which parses the xml and injects to my main '/api' route as JSON. \r\nThis works fine but just seems like extra work. \r\n\r\nI would like to just update the original request right in the beginning and just let hapi work through the normal routes. But I'm not sure how to edit the request.raw.req: IncomingMessage.\r\n\r\nCan anyone suggest a cleaner way of doing this?\r\n\r\nWhere I would like to update and change the request:\r\n```javascript\r\nserver.ext('onRequest', function (request, reply) {\r\n    if(request.method == 'post' && (request.headers['content-type'] == 'application/xml' || request.headers['content-type'] == 'text/xml'))\r\n        //buffer the response stream\r\n        Wreck.read(request.raw.req, null, function (err, body) {\r\n            var stream = Wreck.toReadableStream(body);\r\n            stream.pipe(FakeToe.createParser(function (err, result) {   \r\n                // TODO How to update the original request?\r\n                console.log(result); // Object\r\n            }));\r\n        });\r\n    return reply.continue();\r\n});\r\n```\r\nWorking redirect hack:\r\n```javascript\r\nserver.ext('onRequest', function (request, reply) {\r\n    if(request.method == 'post' && (request.headers['content-type'] == 'application/xml' || request.headers['content-type'] == 'text/xml'))\r\n        request.setUrl('/xml2json');\r\n    return reply.continue();\r\n});\r\n\r\nserver.route({\r\n    method: 'POST',\r\n    path: '/xml2json',\r\n    config: {\r\n        handler: function (request, reply) {\r\n            var stream = Wreck.toReadableStream(request.payload);\r\n            stream.pipe(FakeToe.createParser(function (error, result) {\r\n                var options = {\r\n                    url: '/api',\r\n                    payload: JSON.stringify(result.data),\r\n                    method: 'POST'\r\n                };\r\n                server.inject(options, function (res){\r\n                    reply(res.payload);\r\n                });\r\n            }));\r\n        },\r\n        payload: {\r\n            output: 'data',\r\n            parse: false,\r\n            allow: 'application/xml'\r\n        }\r\n    }\r\n});\r\n\r\nserver.route({\r\n    method: 'POST',\r\n    path: '/api',\r\n    config: {\r\n        handler: function (request, reply) {\r\n            return reply({test:'test',payload:request.payload});\r\n        },\r\n        validate: {\r\n            payload: {\r\n                key1: Joi.string().required(),\r\n                key2: Joi.string().required()\r\n            }\r\n        }\r\n    }\r\n});\r\n```\r\nXML POST\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<data>\r\n    <key1>123456</key1>\r\n    <key2>123456</key2>\r\n</data>\r\n```\r\n\r\nThanks in advance."}}