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'));
|
||||
}
|
||||
|
||||
@@ -9,36 +9,36 @@
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="popup-flex hiddable-container">
|
||||
<div class="popup-body" id="popup-body">
|
||||
<div class="popup-button-close-container">
|
||||
<button type="button" class="popup-button-close"> X </button>
|
||||
</div>
|
||||
<div class="popup-header-table hiddable-popup-option" id="history-headers-table">
|
||||
<table id="header-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Header Name
|
||||
</th>
|
||||
<div class="popup-flex hiddable-container">
|
||||
<div class="popup-body" id="popup-body">
|
||||
<div class="popup-button-close-container">
|
||||
<button type="button" class="popup-button-close"> X </button>
|
||||
</div>
|
||||
<div class="popup-header-table hiddable-popup-option" id="history-headers-table">
|
||||
<table id="header-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Header Name
|
||||
</th>
|
||||
|
||||
<th>
|
||||
Header Value
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="header-history-table-body">
|
||||
<th>
|
||||
Header Value
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="header-history-table-body">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="popup-request-body hiddable-popup-option" id="history-request-body">
|
||||
<pre class="code-content" id="history-request-body-content">
|
||||
<code id="code-highlight-content"></code>
|
||||
</pre>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="popup-request-body hiddable-popup-option" id="history-request-body">
|
||||
<pre class="code-content" id="history-request-body-content">
|
||||
<code id="code-highlight-content"></code>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="tool extended">
|
||||
<div class="tool-context">
|
||||
|
||||
Reference in New Issue
Block a user