RCTURLRequestDelegate.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <Foundation/Foundation.h>
  8. /**
  9. * An abstract interface used by request handler modules to send
  10. * data back over the bridge back to JS.
  11. */
  12. @protocol RCTURLRequestDelegate <NSObject>
  13. /**
  14. * Call this when you send request data to the server. This is used to track
  15. * upload progress, so should be called multiple times for large request bodies.
  16. */
  17. - (void)URLRequest:(id)requestToken didSendDataWithProgress:(int64_t)bytesSent;
  18. /**
  19. * Call this when you first receives a response from the server. This should
  20. * include response headers, etc.
  21. */
  22. - (void)URLRequest:(id)requestToken didReceiveResponse:(NSURLResponse *)response;
  23. /**
  24. * Call this when you receive data from the server. This can be called multiple
  25. * times with partial data chunks, or just once with the full data packet.
  26. */
  27. - (void)URLRequest:(id)requestToken didReceiveData:(NSData *)data;
  28. /**
  29. * Call this when the request is complete and/or if an error is encountered.
  30. * For a successful request, the error parameter should be nil.
  31. */
  32. - (void)URLRequest:(id)requestToken didCompleteWithError:(NSError *)error;
  33. @end