Skip to content

Commit 3ba7856

Browse files
committed
fix: 修复 JSON Content-Type
1 parent 183a8a9 commit 3ba7856

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Rewrite-Parser.beta.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,9 @@ if (binaryInfo != null && binaryInfo.length > 0) {
12731273
if (/(?:reject|302|307|header)$/.test(rwtype))
12741274
URLRewrite.push(mark + noteK + rwptn + ' ' + rwvalue + ' ' + rwtype)
12751275
if (/reject-dict/.test(rwtype))
1276-
MapLocal.push(mark + noteK + rwptn + ' data-type=text data="{}" status-code=200')
1276+
MapLocal.push(
1277+
mark + noteK + rwptn + ' data-type=text data="{}" status-code=200 header="Content-Type:application/json"'
1278+
)
12771279
if (/reject-array/.test(rwtype))
12781280
MapLocal.push(mark + noteK + rwptn + ' data-type=text data="[]" status-code=200')
12791281
if (/reject-200/.test(rwtype)) MapLocal.push(mark + noteK + rwptn + ' data-type=text data=" " status-code=200')
@@ -2132,7 +2134,7 @@ function getMockInfo(x, mark, y) {
21322134
// Loon data-type: body的类型,json,text,css,html,javascript,plain,png,gif,jpeg,tiff,svg,mp4,form-data 应该设置对应的 Content-Type
21332135
switch (mocktype) {
21342136
case 'json':
2135-
mockheader = 'Content-Type:text/json'
2137+
mockheader = 'Content-Type:application/json'
21362138
break
21372139
case 'text':
21382140
mockheader = 'Content-Type:text/plain'

Rewrite-Parser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,9 @@ if (binaryInfo != null && binaryInfo.length > 0) {
12731273
if (/(?:reject|302|307|header)$/.test(rwtype))
12741274
URLRewrite.push(mark + noteK + rwptn + ' ' + rwvalue + ' ' + rwtype)
12751275
if (/reject-dict/.test(rwtype))
1276-
MapLocal.push(mark + noteK + rwptn + ' data-type=text data="{}" status-code=200')
1276+
MapLocal.push(
1277+
mark + noteK + rwptn + ' data-type=text data="{}" status-code=200 header="Content-Type:application/json"'
1278+
)
12771279
if (/reject-array/.test(rwtype))
12781280
MapLocal.push(mark + noteK + rwptn + ' data-type=text data="[]" status-code=200')
12791281
if (/reject-200/.test(rwtype)) MapLocal.push(mark + noteK + rwptn + ' data-type=text data=" " status-code=200')
@@ -2132,7 +2134,7 @@ function getMockInfo(x, mark, y) {
21322134
// Loon data-type: body的类型,json,text,css,html,javascript,plain,png,gif,jpeg,tiff,svg,mp4,form-data 应该设置对应的 Content-Type
21332135
switch (mocktype) {
21342136
case 'json':
2135-
mockheader = 'Content-Type:text/json'
2137+
mockheader = 'Content-Type:application/json'
21362138
break
21372139
case 'text':
21382140
mockheader = 'Content-Type:text/plain'

0 commit comments

Comments
 (0)