Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 8a39f93e62e20f86b9d3a73e598be4462e6c01a7 1 parent 9208101
@blakewatters blakewatters authored
View
5 Code/Network/RKResponse.h
@@ -171,6 +171,11 @@
- (BOOL)isCreated;
/**
+ * Indicates an HTTP response code of 204
+ */
+- (BOOL)isNoContent;
+
+/**
* Indicates an HTTP response code of 304
*/
- (BOOL)isNotModified;
View
4 Code/Network/RKResponse.m
@@ -336,6 +336,10 @@ - (BOOL)isCreated {
return ([self statusCode] == 201);
}
+- (BOOL)isNoContent {
+ return ([self statusCode] == 204);
+}
+
- (BOOL)isNotModified {
return ([self statusCode] == 304);
}
View
4 Code/ObjectMapping/RKObjectLoader.m
@@ -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
36 Rakefile
@@ -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
1  Specs/Server/server.rb
@@ -79,6 +79,7 @@ class RestKit::SpecServer < Sinatra::Base
end
post '/204' do
+ status 204
content_type 'application/json'
""
end
Please sign in to comment.
Something went wrong with that request. Please try again.