Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b30f4c7b
Unverified
Commit
b30f4c7b
authored
Mar 16, 2020
by
Hugo Häggmark
Committed by
GitHub
Mar 16, 2020
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: fixes issue with headers property with different casing (#22778)
Fixes #22756
parent
7b5b8ad3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
public/app/core/services/backend_srv.ts
+38
-12
public/app/core/specs/backend_srv.test.ts
+0
-0
No files found.
public/app/core/services/backend_srv.ts
View file @
b30f4c7b
...
...
@@ -589,12 +589,10 @@ export const parseUrlFromOptions = (options: BackendSrvRequest): string => {
export
const
parseInitFromOptions
=
(
options
:
BackendSrvRequest
):
RequestInit
=>
{
const
method
=
options
.
method
;
const
headers
=
{
'Content-Type'
:
'application/json'
,
Accept
:
'application/json, text/plain, */*'
,
...
options
.
headers
,
};
const
body
=
parseBody
({
...
options
,
headers
});
const
headers
=
parseHeaders
(
options
);
const
isAppJson
=
isContentTypeApplicationJson
(
headers
);
const
body
=
parseBody
(
options
,
isAppJson
);
return
{
method
,
headers
,
...
...
@@ -602,14 +600,42 @@ export const parseInitFromOptions = (options: BackendSrvRequest): RequestInit =>
};
};
const
parseBody
=
(
options
:
BackendSrvRequest
)
=>
{
if
(
!
options
.
data
||
typeof
options
.
data
===
'string'
)
{
return
options
.
data
;
export
const
parseHeaders
=
(
options
:
BackendSrvRequest
)
=>
{
const
headers
=
new
Headers
({
'Content-Type'
:
'application/json'
,
Accept
:
'application/json, text/plain, */*'
,
});
if
(
options
&&
options
.
headers
)
{
Object
.
keys
(
options
.
headers
).
forEach
(
key
=>
{
headers
.
set
(
key
,
options
.
headers
[
key
]);
});
}
return
headers
;
};
export
const
isContentTypeApplicationJson
=
(
headers
:
Headers
)
=>
{
if
(
!
headers
)
{
return
false
;
}
const
contentType
=
headers
.
get
(
'content-type'
);
if
(
contentType
&&
contentType
.
toLowerCase
()
===
'application/json'
)
{
return
true
;
}
return
false
;
};
export
const
parseBody
=
(
options
:
BackendSrvRequest
,
isAppJson
:
boolean
)
=>
{
if
(
!
options
)
{
return
options
;
}
if
(
options
.
headers
[
'Content-Type'
]
===
'application/json
'
)
{
return
JSON
.
stringify
(
options
.
data
)
;
if
(
!
options
.
data
||
typeof
options
.
data
===
'string
'
)
{
return
options
.
data
;
}
return
new
URLSearchParams
(
options
.
data
);
return
isAppJson
?
JSON
.
stringify
(
options
.
data
)
:
new
URLSearchParams
(
options
.
data
);
};
public/app/core/specs/backend_srv.test.ts
View file @
b30f4c7b
This diff is collapsed.
Click to expand it.
Kornkitt Poolsup
@Doratong24
mentioned in commit
a0c6afa0
Mar 05, 2021
mentioned in commit
a0c6afa0
mentioned in commit a0c6afa0a5205fbc5c5af62d93dcdb47c8d8ea8e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment