From ae2940184124fc8ea425ff570d00ef45ea766abe Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Wed, 20 Jul 2011 21:55:10 -0400 Subject: [PATCH] Added specs for zero-length Content-Length header when params is nil or empty --- Code/Network/RKRequest.m | 4 ++- RestKit.xcodeproj/project.pbxproj | 4 +-- .../xcshareddata/xcschemes/UISpec.xcscheme | 11 +++--- Specs/Network/RKRequestSpec.m | 35 ++++++++++++++++++ Specs/ObjectMapping/RKObjectManagerSpec.m | 36 +++++++++++++++++++ Specs/Server/server.rb | 6 ++++ 6 files changed, 88 insertions(+), 8 deletions(-) diff --git a/Code/Network/RKRequest.m b/Code/Network/RKRequest.m index a45945fd..fe5a85bb 100644 --- a/Code/Network/RKRequest.m +++ b/Code/Network/RKRequest.m @@ -178,7 +178,9 @@ if ([_params respondsToSelector:@selector(HTTPHeaderValueForContentLength)]) { [_URLRequest setValue:[NSString stringWithFormat:@"%d", [_params HTTPHeaderValueForContentLength]] forHTTPHeaderField:@"Content-Length"]; } - } + } else { + [_URLRequest setValue:@"0" forHTTPHeaderField:@"Content-Length"]; + } // Add authentication headers so we don't have to deal with an extra cycle for each message requiring basic auth. if (self.forceBasicAuthentication) { diff --git a/RestKit.xcodeproj/project.pbxproj b/RestKit.xcodeproj/project.pbxproj index 35d80926..5da0f507 100644 --- a/RestKit.xcodeproj/project.pbxproj +++ b/RestKit.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 13924B7913AAB91700DD5078 /* libUISpec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13924B7813AAB91700DD5078 /* libUISpec.a */; }; 25064735138DF17C0002F2FE /* RKManagedObjectSeeder.m in Sources */ = {isa = PBXBuildFile; fileRef = 253A088912551D8D00976E89 /* RKManagedObjectSeeder.m */; }; 250C296C13411E60000A3551 /* RKRequestQueueSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = 250C296B13411E60000A3551 /* RKRequestQueueSpec.m */; }; 250C29FD134185D2000A3551 /* RKNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 250C29FB134185CE000A3551 /* RKNetwork.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -110,6 +109,7 @@ 256FD651112C7B780077F340 /* RKMappableObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 256FD64F112C7B780077F340 /* RKMappableObject.m */; }; 256FD652112C7B780077F340 /* RKMappableAssociation.m in Sources */ = {isa = PBXBuildFile; fileRef = 256FD650112C7B780077F340 /* RKMappableAssociation.m */; }; 256FDE55112DB0B90077F340 /* RKObjectMapperSpecModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 256FDE54112DB0B90077F340 /* RKObjectMapperSpecModel.m */; }; + 25716F6F13D7979A00572BD9 /* libUISpec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13924B7513AAB8F500DD5078 /* libUISpec.a */; }; 257D2D7013759D70008E9649 /* RKObjectMappingResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 257D2D6E13759D6F008E9649 /* RKObjectMappingResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 257D2D7113759D70008E9649 /* RKObjectMappingResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 257D2D6F13759D6F008E9649 /* RKObjectMappingResult.m */; }; 257FB677139559A4003A628E /* RKManagedObjectMapping.h in Headers */ = {isa = PBXBuildFile; fileRef = 257FB675139559A4003A628E /* RKManagedObjectMapping.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -755,7 +755,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 13924B7913AAB91700DD5078 /* libUISpec.a in Frameworks */, + 25716F6F13D7979A00572BD9 /* libUISpec.a in Frameworks */, 25A1CB50138419D900A7D5C9 /* libRestKitJSONParserJSONKit.a in Frameworks */, 25A1CB51138419D900A7D5C9 /* libRestKitJSONParserSBJSON.a in Frameworks */, 25A1CB52138419D900A7D5C9 /* libRestKitXMLParserLibxml.a in Frameworks */, diff --git a/RestKit.xcodeproj/xcshareddata/xcschemes/UISpec.xcscheme b/RestKit.xcodeproj/xcshareddata/xcschemes/UISpec.xcscheme index dccedb83..ab103708 100644 --- a/RestKit.xcodeproj/xcshareddata/xcschemes/UISpec.xcscheme +++ b/RestKit.xcodeproj/xcshareddata/xcschemes/UISpec.xcscheme @@ -49,7 +49,7 @@ launchStyle = "0" useCustomWorkingDirectory = "NO" buildConfiguration = "Debug" - enablesOpenGLESFrameCapture = "YES"> + debugDocumentVersioning = "YES"> + value = "itShouldPUTWithParams" + isEnabled = "YES"> + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> {}, :secondUser => {}}.to_json end + put '/ping' do + status 200 + content_type 'application/json' + params.to_json + end + # start the server if ruby file executed directly run! if app_file == $0 end