Permalink
Browse files

Add support for handling 204 'No Content' responses. fixes #450

  • Loading branch information...
1 parent 9208101 commit 8a39f93e62e20f86b9d3a73e598be4462e6c01a7 @blakewatters blakewatters committed Nov 30, 2011
Showing with 17 additions and 33 deletions.
  1. +5 −0 Code/Network/RKResponse.h
  2. +4 −0 Code/Network/RKResponse.m
  3. +4 −0 Code/ObjectMapping/RKObjectLoader.m
  4. +3 −33 Rakefile
  5. +1 −0 Specs/Server/server.rb
@@ -171,6 +171,11 @@
- (BOOL)isCreated;
/**
+ * Indicates an HTTP response code of 204
+ */
+- (BOOL)isNoContent;
+
+/**
* Indicates an HTTP response code of 304
*/
- (BOOL)isNotModified;
@@ -336,6 +336,10 @@ - (BOOL)isCreated {
return ([self statusCode] == 201);
}
+- (BOOL)isNoContent {
+ return ([self statusCode] == 204);
+}
+
- (BOOL)isNotModified {
return ([self statusCode] == 304);
}
@@ -254,6 +254,10 @@ - (BOOL)isResponseMappable {
[self finalizeLoad:NO error:self.response.failureError];
return NO;
+ } else if ([self.response isNoContent]) {
+ // The No Content (204) response will never have a message body or a MIME Type. Invoke the delegate with self
+ [self informDelegateOfObjectLoadWithResultDictionary:[NSDictionary dictionaryWithObject:self forKey:@""]];
+ return NO;
} else if (NO == [self canParseMIMEType:[self.response MIMEType]]) {
// We can't parse the response, it's unmappable regardless of the status code
RKLogWarning(@"Encountered unexpected response with status code: %d (MIME Type: %@)", self.response.statusCode, self.response.MIMEType);
View
@@ -1,36 +1,7 @@
require 'rubygems'
-begin
- gem 'uispecrunner'
- require 'uispecrunner'
- require 'uispecrunner/options'
-rescue LoadError => error
- puts "Unable to load UISpecRunner: #{error}"
-end
-
-namespace :uispec do
- desc "Run all specs"
- task :all do
- options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
- uispec_runner = UISpecRunner.new(options)
- uispec_runner.run_all!
- end
-
- desc "Run all unit specs (those that implement UISpecUnit)"
- task :units do
- options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
- uispec_runner = UISpecRunner.new(options)
- uispec_runner.run_protocol!('UISpecUnit')
- end
-
- desc "Run all integration specs (those that implement UISpecIntegration)"
- task :integration do
- options = UISpecRunner::Options.from_file('uispec.opts') rescue {}
- uispec_runner = UISpecRunner.new(options)
- uispec_runner.run_protocol!('UISpecIntegration')
- end
-
- desc "Run the Spec server via Shotgun"
+namespace :spec do
+ desc "Run the RestKit spec server"
task :server do
server_path = File.dirname(__FILE__) + '/Specs/Server/server.rb'
system("ruby #{server_path}")
@@ -57,8 +28,7 @@ def run(command, min_exit_status = 0)
return $?.exitstatus
end
-desc "Run all specs"
-task :default => 'uispec:all'
+task :default => 'spec:server'
desc "Build RestKit for iOS and Mac OS X"
task :build do
View
@@ -79,6 +79,7 @@ class RestKit::SpecServer < Sinatra::Base
end
post '/204' do
+ status 204
content_type 'application/json'
""
end

0 comments on commit 8a39f93

Please sign in to comment.