Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove duplicate content type header #537

Merged
merged 3 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/app/services/actions/query-action-creator-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ export async function anonymousRequest(dispatch: Function, query: IQuery) {
const escapedUrl = encodeURIComponent(query.sampleUrl);
const graphUrl = `https://proxy.apisandbox.msdn.microsoft.com/svc?url=${escapedUrl}`;
const sampleHeaders: any = {};

if (query.sampleHeaders) {
if (query.sampleHeaders && query.sampleHeaders.length > 0) {
query.sampleHeaders.forEach(header => {
if (header.name !== '' && header.value !== '') {
sampleHeaders[header.name] = header.value;
}
sampleHeaders[header.name] = header.value;
});
}

Expand Down Expand Up @@ -101,11 +98,14 @@ const makeRequest = (httpVerb: string, scopes: string[]): Function => {
const sampleHeaders: any = {};
sampleHeaders.SdkVersion = 'GraphExplorer/4.0';

if (query.sampleHeaders) {
if (query.sampleHeaders && query.sampleHeaders.length > 0) {
query.sampleHeaders.forEach(header => {
if (header.name !== '' && header.value !== '') {
sampleHeaders[header.name] = header.value;

// We are relying on the graph client to set the content type header.
if (header.name.toLowerCase() === 'content-type') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check that content-type value is set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on the graph client to set the content type. Please add comment that content-type header is being set by Graph JavaScript client.

return;
}
sampleHeaders[header.name] = header.value;
});
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/services/actions/samples-action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export function fetchSamples(): Function {
const res = await response.json();
return dispatch(fetchSamplesSuccess(res.sampleQueries));
} catch (error) {
const errorCode = await error.text();
return dispatch(fetchSamplesError({ error: errorCode }));
return dispatch(fetchSamplesError({ error }));
}
};
}