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

$http service #609

Closed
wants to merge 28 commits into from
Closed

$http service #609

wants to merge 28 commits into from

Conversation

vojtajina
Copy link
Contributor

New $http service (replacement for $xhr) along with $httpBackend and $httpBackend mocks...

We still need to polish the docs...

@vojtajina
Copy link
Contributor Author

All Misko's comments processed and rebased to latest master.

@vojtajina
Copy link
Contributor Author

Added some more commits, please review...

  • handling 0 status with file protocol
  • injectable cache into $http (per request)
  • using it in ng:include, ng:view
  • rebased to latest master

vojtajina and others added 28 commits November 18, 2011 16:22
Breaks "JSON" xhr method is now called "JSONP"
If jsonp is not successfull, we return internal status -2.
This internal status should by normalized by $xhr into 0,
but $xhr needs to distinguish between jsonp-error/abort/timeout (all status 0).
IE6, IE7 is sync when serving content from cache.
We want consistent api, so we have to use setTimeout to make it async.
Timeouted request responds internal status code -1, which should be normalized
into 0 by $xhr.
Features:
- aborting requests
- more flexible callbacks (per status code)
- custom request headers (per request)
- access to response headers
- custom transform functions (both request, response)
- caching
- shortcut methods (get, head, post, put, delete, patch, jsonp)
- exposing pendingCount()
- setting timeout
Breaks Renaming $xhr to $http
Breaks Takes one parameter now - configuration object
Breaks $xhr.cache removed - use configuration cache: true instead
Breaks $xhr.error, $xhr.bulk removed
Breaks Callback functions get parameters: response, status, headers
Closes angular#38
Closes angular#80
Closes angular#180
Closes angular#299
Closes angular#342
Closes angular#395
Closes angular#413
Closes angular#414
Closes angular#507
$httpBackend mock allows:
- expecting (asserting) requests
- stubbing (responding without asserting)

Add empty $httpBackend service (currently just wrapper for $browser.xhr)
- remove whole $browser.xhr stuff
- remove whole mock $browser.xhr stuff
- add $httpBackend service + migrate unit tests from $browser
- add temporary API to access $browser's outstandingRequests count
- $http.pendingRequests is now an array of pending requests
- each request (its future object) has public property configuration
Breaks Disabling $resource caching for the moment.
+ rename verifyExpectations to verifyNoOutstandingExpectation
Browsers return always 0 status code for "file" protocol, so we convert them into 200/404.
You can still use cache: true, which will use $http's default cache.
…emplate

The way we determine whether it's json is lame anyway. We need to change that.
We should probably check the content type header...
Instead of doing all the stuff in these widgets (checking cache, etc..) we can rely on $http now...
@vojtajina
Copy link
Contributor Author

Closing, it's already in master...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants