XML request bodies are now formatted
This commit is contained in:
		@@ -77,10 +77,41 @@ function showHeadersHistory(element){
 | 
			
		||||
    showPopup();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function formatXML(xml) {
 | 
			
		||||
    const address = window.location.protocol + "//" + window.location.hostname + ":" + 8082 + "/prettify";
 | 
			
		||||
    var data = {
 | 
			
		||||
        data: xml,
 | 
			
		||||
        process: "",
 | 
			
		||||
        processor: "libxml",
 | 
			
		||||
        version: "1.0"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log("formattedXML");
 | 
			
		||||
    fetch(address, {
 | 
			
		||||
        method: 'POST',
 | 
			
		||||
        body: JSON.stringify(data)
 | 
			
		||||
    })
 | 
			
		||||
        .then(async (response) => {
 | 
			
		||||
            const promise = response.json();
 | 
			
		||||
            if (!response.ok) {
 | 
			
		||||
                throw Error(await promise);
 | 
			
		||||
            }
 | 
			
		||||
            return promise;
 | 
			
		||||
        })
 | 
			
		||||
        .then((data) => {
 | 
			
		||||
            document.getElementById('code-highlight-content').innerText = data.result;
 | 
			
		||||
            highlightSyntax('code-highlight-content');
 | 
			
		||||
            //console.log(data.result);
 | 
			
		||||
        })
 | 
			
		||||
        .catch((error) => {
 | 
			
		||||
            console.error('Error:', error);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function showRequestBody(element){
 | 
			
		||||
    requestBody = "";
 | 
			
		||||
    historyRequestBody = historyJson[element.id].requestBody;
 | 
			
		||||
    console.log(historyRequestBody);
 | 
			
		||||
    switch(historyJson[element.id].headers["content-type"]){
 | 
			
		||||
        case "application/json":{
 | 
			
		||||
            const address = window.location.protocol + "//" + window.location.hostname + ":" + 8081 + "/json/formatting"
 | 
			
		||||
@@ -97,6 +128,7 @@ function showRequestBody(element){
 | 
			
		||||
                })
 | 
			
		||||
                .then((data) => {
 | 
			
		||||
                    requestBody = '<code class="language=json">'+data.data+'</code>';
 | 
			
		||||
 | 
			
		||||
                    document.getElementById('history-request-body-content').innerHTML = requestBody;
 | 
			
		||||
                    hljs.highlightElement(document.getElementById('history-request-body-content'));
 | 
			
		||||
                })
 | 
			
		||||
@@ -106,13 +138,14 @@ function showRequestBody(element){
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case "application/xml":{
 | 
			
		||||
            document.getElementById('code-highlight-content').innerText = historyRequestBody;
 | 
			
		||||
            highlightSyntax('code-highlight-content');
 | 
			
		||||
            //document.getElementById('code-highlight-content').innerText = historyRequestBody;
 | 
			
		||||
            formatXML(historyRequestBody);
 | 
			
		||||
            
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        default:{
 | 
			
		||||
            requestBody = '<code>'+historyRequestBody+'</code>'
 | 
			
		||||
            requestBody = '<code>'+historyRequestBody+'</code>';
 | 
			
		||||
            document.getElementById('history-request-body-content').innerText = requestBody;
 | 
			
		||||
            hljs.highlightElement(document.getElementById('history-request-body-content'));
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user