Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($templateRequest): Set Accept header on template requests #11868

Closed

Conversation

luckycadow
Copy link

Set the Accept header on HTTP requests for templates to text/html, text/ng-template.
Previously the default request headers sent by $http were used.

Closes #6860

Review on Reviewable

Set the `Accept` header on HTTP requests for templates to `text/html, text/ng-template`.
Previously the default request headers sent by `$http` were used.

Closes angular#6860
@@ -36,7 +36,8 @@ function $TemplateRequestProvider() {

var httpOptions = {
cache: $templateCache,
transformResponse: transformResponse
transformResponse: transformResponse,
headers: { 'Accept': 'text/html, text/ng-template' }
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a feeling it would be safest to move this to the provider so that it could always be modified on an app by app basis.

Choose a reason for hiding this comment

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

Agreed. The proposal here sounds like a good default value.

BTW, this needs tests.

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 28, 2015
It is now possible to configure the Accept header for template requests.
If a value is configured then this will override only the Accept property
of the headers that are passed.
If no value is configured then the request will use the default $http
Accept header.

Thanks to @luckycadow for help on this feature

Closes angular#11868
Closes angular#6860
@petebacondarwin
Copy link
Contributor

We have a new PR that overrides this one, as it is configurable and has tests.

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 28, 2015
It is now possible to configure the Accept header for template requests.
If a value is configured then this will override only the Accept property
of the headers that are passed.
If no value is configured then the request will use the default $http
Accept header.

Thanks to @luckycadow for help on this feature

Closes angular#11868
Closes angular#6860
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 28, 2015
It is now possible to configure the options sent to $http for template requests.
If no value is configured then the request will use the default $http options.

Thanks to @luckycadow for help on this feature

Closes angular#11868
Closes angular#6860
petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request Oct 28, 2015
It is now possible to configure the options sent to $http for template requests.
If no value is configured then the request will use the default $http options.

Thanks to @luckycadow for help on this feature

Closes angular#11868
Closes angular#6860
petebacondarwin added a commit that referenced this pull request Oct 28, 2015
It is now possible to configure the options sent to $http for template requests.
If no value is configured then the request will use the default $http options.

Thanks to @luckycadow for help on this feature

Closes #13188
Closes #11868
Closes #6860
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angular directive templateUrl should allow "text/html" Accept and content-type headers
4 participants