DELETEResponse.m 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #import "DELETEResponse.h"
  2. #import "HTTPLogging.h"
  3. // HTTP methods: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
  4. // HTTP headers: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
  5. // HTTP status codes: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  6. static const int httpLogLevel = HTTP_LOG_LEVEL_WARN;
  7. @implementation DELETEResponse
  8. - (id) initWithFilePath:(NSString*)path {
  9. if ((self = [super init])) {
  10. BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path];
  11. if ([[NSFileManager defaultManager] removeItemAtPath:path error:NULL]) {
  12. _status = exists ? 200 : 204;
  13. } else {
  14. HTTPLogError(@"Failed deleting \"%@\"", path);
  15. _status = 404;
  16. }
  17. }
  18. return self;
  19. }
  20. - (UInt64) contentLength {
  21. return 0;
  22. }
  23. - (UInt64) offset {
  24. return 0;
  25. }
  26. - (void)setOffset:(UInt64)offset {
  27. ;
  28. }
  29. - (NSData*) readDataOfLength:(NSUInteger)length {
  30. return nil;
  31. }
  32. - (BOOL) isDone {
  33. return YES;
  34. }
  35. - (NSInteger) status {
  36. return _status;
  37. }
  38. @end