Skip to content

Commit 535b179

Browse files
authored
Add charset to REST Debug panel's Content-Type (#1092)
1 parent 8bc6175 commit 535b179

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/commands/restDebugPanel.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -391,16 +391,18 @@ export class RESTDebugPanel {
391391
message.headersText.split(/\r?\n/).forEach((line) => {
392392
line = line.trim();
393393
if (line != "" && !line.startsWith("#")) {
394-
headers[line.slice(0, line.indexOf(":")).trim()] = line.slice(line.indexOf(":") + 1).trim();
394+
headers[line.slice(0, line.indexOf(":")).trim().toLowerCase()] = line
395+
.slice(line.indexOf(":") + 1)
396+
.trim();
395397
}
396398
});
397399
if (
398-
headers["Authorization"] == undefined &&
400+
headers["authorization"] == undefined &&
399401
typeof api.config.username === "string" &&
400402
typeof api.config.password === "string"
401403
) {
402404
// Use the server connection's auth if the user didn't specify any
403-
headers["Authorization"] = `Basic ${Buffer.from(`${api.config.username}:${api.config.password}`).toString(
405+
headers["authorization"] = `Basic ${Buffer.from(`${api.config.username}:${api.config.password}`).toString(
404406
"base64"
405407
)}`;
406408
}
@@ -410,16 +412,16 @@ export class RESTDebugPanel {
410412
// Set the Content-Type header using bodyType
411413
switch (message.bodyType) {
412414
case "JSON":
413-
headers["Content-Type"] = "application/json";
415+
headers["content-type"] = "application/json; charset=utf-8";
414416
break;
415417
case "XML":
416-
headers["Content-Type"] = "application/xml";
418+
headers["content-type"] = "application/xml; charset=utf-8";
417419
break;
418420
case "Text":
419-
headers["Content-Type"] = "text/plain";
421+
headers["content-type"] = "text/plain; charset=utf-8";
420422
break;
421423
case "HTML":
422-
headers["Content-Type"] = "text/html";
424+
headers["content-yype"] = "text/html; charset=utf-8";
423425
break;
424426
}
425427
}

0 commit comments

Comments
 (0)