diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..955bdbe --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# files created by Xcode 3 or older +*.pbxuser +*.mode1 +*.mode1v3 +*.mode2v3 +*.perspectivev3 +*.xcclassmodel/ +# files created by Xcode 4 +xcuserdata/ +# build products +*.build/ +build/ +DerivedData/ +# Misc +.svn +.DS_Store +*~ \ No newline at end of file diff --git a/HTTPClient.xcodeproj/project.pbxproj b/HTTPClient.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f54c807 --- /dev/null +++ b/HTTPClient.xcodeproj/project.pbxproj @@ -0,0 +1,426 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 12533B7415FF10F300D38F60 /* http_request.h in Headers */ = {isa = PBXBuildFile; fileRef = 12533B6E15FF10F300D38F60 /* http_request.h */; }; + 12533B7515FF10F300D38F60 /* http_response.h in Headers */ = {isa = PBXBuildFile; fileRef = 12533B6F15FF10F300D38F60 /* http_response.h */; }; + 12533B7615FF10F300D38F60 /* HTTPClient.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 12533B7015FF10F300D38F60 /* HTTPClient.hpp */; }; + 12533B7715FF10F300D38F60 /* HTTPClientConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 12533B7115FF10F300D38F60 /* HTTPClientConfig.h */; }; + 12533B9315FF111200D38F60 /* http_request.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12533B8415FF111100D38F60 /* http_request.cpp */; }; + 12533B9415FF111200D38F60 /* http_response.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12533B8515FF111100D38F60 /* http_response.cpp */; }; + 12533BB215FF116800D38F60 /* httpclient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 12533BAD15FF116800D38F60 /* httpclient.cpp */; }; + 12533BB915FF140900D38F60 /* libboost_date_time-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB415FF140800D38F60 /* libboost_date_time-mt.dylib */; }; + 12533BBA15FF140900D38F60 /* libboost_filesystem-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB515FF140800D38F60 /* libboost_filesystem-mt.dylib */; }; + 12533BBB15FF140900D38F60 /* libboost_regex-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB615FF140900D38F60 /* libboost_regex-mt.dylib */; }; + 12533BBC15FF140900D38F60 /* libboost_system-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB715FF140900D38F60 /* libboost_system-mt.dylib */; }; + 12533BBD15FF140900D38F60 /* libboost_thread-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB815FF140900D38F60 /* libboost_thread-mt.dylib */; }; + 12533BBF15FF143A00D38F60 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BBE15FF143A00D38F60 /* libssl.dylib */; }; + 12533BC115FF144B00D38F60 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BC015FF144B00D38F60 /* libcrypto.dylib */; }; + 12533BC415FF146700D38F60 /* HTTPClient.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533B4215FF0FEA00D38F60 /* HTTPClient.dylib */; }; + 12533BC515FF159D00D38F60 /* libboost_date_time-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB415FF140800D38F60 /* libboost_date_time-mt.dylib */; }; + 12533BC615FF159D00D38F60 /* libboost_filesystem-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB515FF140800D38F60 /* libboost_filesystem-mt.dylib */; }; + 12533BC715FF159D00D38F60 /* libboost_regex-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB615FF140900D38F60 /* libboost_regex-mt.dylib */; }; + 12533BC815FF159D00D38F60 /* libboost_system-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB715FF140900D38F60 /* libboost_system-mt.dylib */; }; + 12533BC915FF159D00D38F60 /* libboost_thread-mt.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BB815FF140900D38F60 /* libboost_thread-mt.dylib */; }; + 12533BCC15FF15A400D38F60 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BBE15FF143A00D38F60 /* libssl.dylib */; }; + 12533BCD15FF15AB00D38F60 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 12533BC015FF144B00D38F60 /* libcrypto.dylib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 12533BC215FF146200D38F60 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 12533B3915FF0FE800D38F60 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 12533B4115FF0FEA00D38F60; + remoteInfo = HTTPClient; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 12533B9A15FF115600D38F60 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 12533B4215FF0FEA00D38F60 /* HTTPClient.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = HTTPClient.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + 12533B6915FF10E400D38F60 /* HTTPClientProj.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = HTTPClientProj.xcconfig; path = xcode/HTTPClientProj.xcconfig; sourceTree = SOURCE_ROOT; }; + 12533B6A15FF10E400D38F60 /* HTTPClientTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = HTTPClientTarget.xcconfig; path = xcode/HTTPClientTarget.xcconfig; sourceTree = SOURCE_ROOT; }; + 12533B6E15FF10F300D38F60 /* http_request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_request.h; sourceTree = ""; }; + 12533B6F15FF10F300D38F60 /* http_response.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_response.h; sourceTree = ""; }; + 12533B7015FF10F300D38F60 /* HTTPClient.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HTTPClient.hpp; sourceTree = ""; }; + 12533B7115FF10F300D38F60 /* HTTPClientConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPClientConfig.h; sourceTree = ""; }; + 12533B8415FF111100D38F60 /* http_request.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_request.cpp; sourceTree = ""; }; + 12533B8515FF111100D38F60 /* http_response.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = http_response.cpp; sourceTree = ""; }; + 12533B9C15FF115600D38F60 /* httpclient */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = httpclient; sourceTree = BUILT_PRODUCTS_DIR; }; + 12533BAD15FF116800D38F60 /* httpclient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = httpclient.cpp; sourceTree = ""; }; + 12533BB415FF140800D38F60 /* libboost_date_time-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_date_time-mt.dylib"; path = "../../../../opt/local/lib/libboost_date_time-mt.dylib"; sourceTree = ""; }; + 12533BB515FF140800D38F60 /* libboost_filesystem-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_filesystem-mt.dylib"; path = "../../../../opt/local/lib/libboost_filesystem-mt.dylib"; sourceTree = ""; }; + 12533BB615FF140900D38F60 /* libboost_regex-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_regex-mt.dylib"; path = "../../../../opt/local/lib/libboost_regex-mt.dylib"; sourceTree = ""; }; + 12533BB715FF140900D38F60 /* libboost_system-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_system-mt.dylib"; path = "../../../../opt/local/lib/libboost_system-mt.dylib"; sourceTree = ""; }; + 12533BB815FF140900D38F60 /* libboost_thread-mt.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = "libboost_thread-mt.dylib"; path = "../../../../opt/local/lib/libboost_thread-mt.dylib"; sourceTree = ""; }; + 12533BBE15FF143A00D38F60 /* libssl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libssl.dylib; path = usr/lib/libssl.dylib; sourceTree = SDKROOT; }; + 12533BC015FF144B00D38F60 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = usr/lib/libcrypto.dylib; sourceTree = SDKROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 12533B3F15FF0FEA00D38F60 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 12533BC115FF144B00D38F60 /* libcrypto.dylib in Frameworks */, + 12533BBF15FF143A00D38F60 /* libssl.dylib in Frameworks */, + 12533BB915FF140900D38F60 /* libboost_date_time-mt.dylib in Frameworks */, + 12533BBA15FF140900D38F60 /* libboost_filesystem-mt.dylib in Frameworks */, + 12533BBB15FF140900D38F60 /* libboost_regex-mt.dylib in Frameworks */, + 12533BBC15FF140900D38F60 /* libboost_system-mt.dylib in Frameworks */, + 12533BBD15FF140900D38F60 /* libboost_thread-mt.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 12533B9915FF115600D38F60 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 12533BCD15FF15AB00D38F60 /* libcrypto.dylib in Frameworks */, + 12533BCC15FF15A400D38F60 /* libssl.dylib in Frameworks */, + 12533BC515FF159D00D38F60 /* libboost_date_time-mt.dylib in Frameworks */, + 12533BC615FF159D00D38F60 /* libboost_filesystem-mt.dylib in Frameworks */, + 12533BC715FF159D00D38F60 /* libboost_regex-mt.dylib in Frameworks */, + 12533BC815FF159D00D38F60 /* libboost_system-mt.dylib in Frameworks */, + 12533BC915FF159D00D38F60 /* libboost_thread-mt.dylib in Frameworks */, + 12533BC415FF146700D38F60 /* HTTPClient.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 12533B3715FF0FE700D38F60 = { + isa = PBXGroup; + children = ( + 12533BC015FF144B00D38F60 /* libcrypto.dylib */, + 12533BBE15FF143A00D38F60 /* libssl.dylib */, + 12533BB415FF140800D38F60 /* libboost_date_time-mt.dylib */, + 12533BB515FF140800D38F60 /* libboost_filesystem-mt.dylib */, + 12533BB615FF140900D38F60 /* libboost_regex-mt.dylib */, + 12533BB715FF140900D38F60 /* libboost_system-mt.dylib */, + 12533BB815FF140900D38F60 /* libboost_thread-mt.dylib */, + 12533B4415FF0FEA00D38F60 /* HTTPClient */, + 12533B4315FF0FEA00D38F60 /* Products */, + ); + sourceTree = ""; + }; + 12533B4315FF0FEA00D38F60 /* Products */ = { + isa = PBXGroup; + children = ( + 12533B4215FF0FEA00D38F60 /* HTTPClient.dylib */, + 12533B9C15FF115600D38F60 /* httpclient */, + ); + name = Products; + sourceTree = ""; + }; + 12533B4415FF0FEA00D38F60 /* HTTPClient */ = { + isa = PBXGroup; + children = ( + 12533BA615FF116800D38F60 /* example */, + 12533B7815FF111100D38F60 /* src */, + 12533B6C15FF10F300D38F60 /* include */, + 12533B6915FF10E400D38F60 /* HTTPClientProj.xcconfig */, + 12533B6A15FF10E400D38F60 /* HTTPClientTarget.xcconfig */, + 12533B4515FF0FEA00D38F60 /* Supporting Files */, + ); + path = HTTPClient; + sourceTree = ""; + }; + 12533B4515FF0FEA00D38F60 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 12533B6C15FF10F300D38F60 /* include */ = { + isa = PBXGroup; + children = ( + 12533B6D15FF10F300D38F60 /* HTTPClient */, + ); + path = include; + sourceTree = SOURCE_ROOT; + }; + 12533B6D15FF10F300D38F60 /* HTTPClient */ = { + isa = PBXGroup; + children = ( + 12533B6E15FF10F300D38F60 /* http_request.h */, + 12533B6F15FF10F300D38F60 /* http_response.h */, + 12533B7015FF10F300D38F60 /* HTTPClient.hpp */, + 12533B7115FF10F300D38F60 /* HTTPClientConfig.h */, + ); + path = HTTPClient; + sourceTree = ""; + }; + 12533B7815FF111100D38F60 /* src */ = { + isa = PBXGroup; + children = ( + 12533B8415FF111100D38F60 /* http_request.cpp */, + 12533B8515FF111100D38F60 /* http_response.cpp */, + ); + path = src; + sourceTree = SOURCE_ROOT; + }; + 12533BA615FF116800D38F60 /* example */ = { + isa = PBXGroup; + children = ( + 12533BAD15FF116800D38F60 /* httpclient.cpp */, + ); + path = example; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 12533B4015FF0FEA00D38F60 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 12533B7415FF10F300D38F60 /* http_request.h in Headers */, + 12533B7515FF10F300D38F60 /* http_response.h in Headers */, + 12533B7615FF10F300D38F60 /* HTTPClient.hpp in Headers */, + 12533B7715FF10F300D38F60 /* HTTPClientConfig.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 12533B4115FF0FEA00D38F60 /* HTTPClient */ = { + isa = PBXNativeTarget; + buildConfigurationList = 12533B4F15FF0FEA00D38F60 /* Build configuration list for PBXNativeTarget "HTTPClient" */; + buildPhases = ( + 12533B3E15FF0FEA00D38F60 /* Sources */, + 12533B3F15FF0FEA00D38F60 /* Frameworks */, + 12533B4015FF0FEA00D38F60 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = HTTPClient; + productName = HTTPClient; + productReference = 12533B4215FF0FEA00D38F60 /* HTTPClient.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; + 12533B9B15FF115600D38F60 /* httpclient */ = { + isa = PBXNativeTarget; + buildConfigurationList = 12533BA315FF115600D38F60 /* Build configuration list for PBXNativeTarget "httpclient" */; + buildPhases = ( + 12533B9815FF115600D38F60 /* Sources */, + 12533B9915FF115600D38F60 /* Frameworks */, + 12533B9A15FF115600D38F60 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + 12533BC315FF146200D38F60 /* PBXTargetDependency */, + ); + name = httpclient; + productName = httpclient; + productReference = 12533B9C15FF115600D38F60 /* httpclient */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 12533B3915FF0FE800D38F60 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + }; + buildConfigurationList = 12533B3C15FF0FE800D38F60 /* Build configuration list for PBXProject "HTTPClient" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 12533B3715FF0FE700D38F60; + productRefGroup = 12533B4315FF0FEA00D38F60 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 12533B4115FF0FEA00D38F60 /* HTTPClient */, + 12533B9B15FF115600D38F60 /* httpclient */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 12533B3E15FF0FEA00D38F60 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 12533B9315FF111200D38F60 /* http_request.cpp in Sources */, + 12533B9415FF111200D38F60 /* http_response.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 12533B9815FF115600D38F60 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 12533BB215FF116800D38F60 /* httpclient.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 12533BC315FF146200D38F60 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 12533B4115FF0FEA00D38F60 /* HTTPClient */; + targetProxy = 12533BC215FF146200D38F60 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 12533B4D15FF0FEA00D38F60 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = /opt/local/include/; + LIBRARY_SEARCH_PATHS = /opt/local/lib/; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 12533B4E15FF0FEA00D38F60 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = NO; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = /opt/local/include/; + LIBRARY_SEARCH_PATHS = /opt/local/lib/; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; + }; + name = Release; + }; + 12533B5015FF0FEA00D38F60 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/src/.libs\"", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 12533B5115FF0FEA00D38F60 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/src/.libs\"", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 12533BA415FF115600D38F60 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + USER_HEADER_SEARCH_PATHS = "./include/ /opt/local/include/"; + }; + name = Debug; + }; + 12533BA515FF115600D38F60 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + /opt/local/lib, + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + USER_HEADER_SEARCH_PATHS = "./include/ /opt/local/include/"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 12533B3C15FF0FE800D38F60 /* Build configuration list for PBXProject "HTTPClient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 12533B4D15FF0FEA00D38F60 /* Debug */, + 12533B4E15FF0FEA00D38F60 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 12533B4F15FF0FEA00D38F60 /* Build configuration list for PBXNativeTarget "HTTPClient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 12533B5015FF0FEA00D38F60 /* Debug */, + 12533B5115FF0FEA00D38F60 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 12533BA315FF115600D38F60 /* Build configuration list for PBXNativeTarget "httpclient" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 12533BA415FF115600D38F60 /* Debug */, + 12533BA515FF115600D38F60 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 12533B3915FF0FE800D38F60 /* Project object */; +} diff --git a/HTTPClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/HTTPClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..bb32404 --- /dev/null +++ b/HTTPClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/include/HTTPClient/http_request.h b/include/HTTPClient/http_request.h index ce7c329..7fa2dae 100644 --- a/include/HTTPClient/http_request.h +++ b/include/HTTPClient/http_request.h @@ -276,6 +276,8 @@ private: enum http_proxy_enum { NONE, HTTP_PROXY, HTTPS_PROXY}; enum http_type_enum { PLAIN_HTTP, SSL_HTTPS}; + int redirtimes; + http_proxy_enum http_proxy; http_type_enum http_type; boost::asio::io_service io; diff --git a/include/HTTPClient/http_response.h b/include/HTTPClient/http_response.h index abf0701..a0d9019 100644 --- a/include/HTTPClient/http_response.h +++ b/include/HTTPClient/http_response.h @@ -218,6 +218,11 @@ protected: * Its called automatically as the data is recieved from the http server */ virtual void flush(); + /*! \brief Clear the Body + * + * Used to clear the Body that has been downloaded so far + */ + virtual void clearBody(); /*! \brief Store the URL that is being downloaded * * used by the http_request class only, this function stores the URL that is being downloaded. @@ -226,6 +231,12 @@ protected: * @param[in] url the URL as a sting */ virtual void setURL(std::string url); + /*! \brief Signal that the download has completed + * + * used by the http_request class only, this function indicates that the download is completed. + * it is called automatically when the download has finished. Can be reimplemented in inherited classes to close a file handle for example + */ + virtual void Completed(); friend class http_request; std::string version; @@ -249,6 +260,7 @@ public: protected: void flush(); void setURL(std::string url); + void Completed(); private: bool OpenFile(); bool CloseFile(); diff --git a/src/http_request.cpp b/src/http_request.cpp index b862442..5a6e6c4 100644 --- a/src/http_request.cpp +++ b/src/http_request.cpp @@ -422,9 +422,35 @@ void http_request::receive() } else { - this->response->setBodySize(0); + this->response->setBodySize(0); parser_state = BODY; } + /* once we get here, before starting the Body Download, Check the Status Return Value + * which might depend upon headers (eg, Location) + */ + if ((this->response->getStatus() >= 300) && (this->response->getStatus() < 400)) { + /* Redirect */ + if (this->redirtimes++ > 5) { + this->disconnect(); + LogCritical() << "Redirection Failure. Redirected too many times"; + delete buffer; + return; + } + std::string Location = this->response->getHeader("Location"); + if (Location != "") { + LogTrace() << "Redirecting (" << this->response->getStatus() << ") to " << Location; + this->reset(); + this->send(Location); + delete buffer; + return; + } else { + LogCritical() << "Redirection Failure (" << this->response->getStatus() << "). No Location Specified"; + delete buffer; + return; + } + } + + } else if (*position == ':') position++; @@ -446,7 +472,7 @@ void http_request::receive() { position++; LogTrace() << boost::this_thread::get_id() << "Header key: " << key << " value: " << value; - this->response->setHeaders(key, value); + this->response->setHeaders(key, value); key = ""; parser_state = HEADER_KEY; } @@ -469,6 +495,7 @@ void http_request::receive() { if (e.code() == boost::asio::error::eof) { this->response->setBodySize(this->response->getBody().length()); + this->response->Completed(); } else { delete buffer; @@ -521,29 +548,11 @@ void http_request::disconnect() http_response *http_request::connect(std::string url) { - //http_request request(this->response,this->io_service); - int redirtimes = 0; - while ((this->response->getStatus() < 200) || (this->response->getStatus() >= 300)) { // Send the HTTP request and receive the this->response. this->send(url); - if ((this->response->getStatus() >= 300) && (this->response->getStatus() < 400)) { - /* Redirect */ - if (redirtimes++ > 5) { - this->disconnect(); - LogCritical() << "Redirection Failure. Redirected too many times"; - return this->response; - } - std::string Location = this->response->getHeader("Location"); - if (Location != "") { - LogTrace() << "Redirecting (" << this->response->getStatus() << ") to " << Location; - url = Location; - this->reset(); - } else { - LogCritical() << "Redirection Failure (" << this->response->getStatus() << "). No Location Specified"; - return this->response; - } - } else if ((this->response->getStatus() >= 400) && (this->response->getStatus() < 500)) { + /* redirect Headers are handled above in the recieve function */ + if ((this->response->getStatus() >= 400) && (this->response->getStatus() < 500)) { LogCritical() << "Not Found (" << this->response->getStatus() << ") Error"; this->disconnect(); return this->response; diff --git a/src/http_response.cpp b/src/http_response.cpp index a68a605..cfe8501 100644 --- a/src/http_response.cpp +++ b/src/http_response.cpp @@ -1,5 +1,5 @@ /* - * HTTP Response Base class for libHTTPClient + * HTTP Response Base class for libHTTPClient * Copyright (C) 2012 Justin Hammond * * This library is free software; you can redistribute it and/or @@ -17,113 +17,115 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ -#include "HTTPClient/http_response.h" - +#include "HTTPClient/http_response.h" + #include #include - - -using namespace DynamX::HttpClient; - -http_response::http_response(): body_size(0) -{ - this->reset(); -} - -http_response::~http_response() -{ -} - - -void http_response::reset() -{ - boost::interprocess::scoped_lock(this->TLock); - this->version = "HTTP/1.0"; - this->status = 0; - this->description = "OK"; - this->headers.clear(); - this->body_size = 0; - this->body = ""; + + +using namespace DynamX::HttpClient; +using namespace DynamX::HttpClient::Logging; + + +http_response::http_response(): body_size(0) +{ + this->reset(); +} + +http_response::~http_response() +{ +} + + +void http_response::reset() +{ + boost::interprocess::scoped_lock(this->TLock); + this->version = "HTTP/1.0"; + this->status = 0; + this->description = "OK"; + this->headers.clear(); + this->body_size = 0; + this->body = ""; this->progress = 0; - this->url = ""; -} - - -void http_response::setVersion(std::string ver) { - this->version = ver; -} - -std::string http_response::getVersion() { - return this->version; -} - -void http_response::setStatus(int stat) { - this->status = stat; -} - -int http_response::getStatus() { - return this->status; -} - -void http_response::setDescription(std::string desc) { - this->description = desc; -} -std::string http_response::getDescription() { - return this->description; -} - -void http_response::setHeaders(std::string key, std::string val) { - this->headers.insert(std::pair(key, val)); -} - -std::map::iterator http_response::getHeadersBegin() { - return this->headers.begin(); -} - -std::map::iterator http_response::getHeadersEnd() { - return this->headers.end(); -} -std::string http_response::getHeader(std::string key) { - std::map::iterator iter = this->headers.find(key); - if (iter != this->headers.end()) - return iter->second; - return ""; -} - -void http_response::setBodySize(size_t size) { - boost::interprocess::scoped_lock(this->TLock); - this->body_size = size; -} - -size_t http_response::getBodySize() { - boost::interprocess::scoped_lock(this->TLock); - return this->body_size; -} - -void http_response::setBody(std::string mybod) { - boost::interprocess::scoped_lock(this->TLock); - this->body += mybod; - this->progress += mybod.length(); -} - -void http_response::setBody(char c) { - boost::interprocess::scoped_lock(this->TLock); - this->body += c; - this->progress++; -} -std::string http_response::getBody() { - boost::interprocess::scoped_lock(this->TLock); - return this->body; - -} -size_t http_response::getProgress() { - boost::interprocess::scoped_lock(this->TLock); - return this->progress; + this->url = ""; +} + + +void http_response::setVersion(std::string ver) { + this->version = ver; +} + +std::string http_response::getVersion() { + return this->version; +} + +void http_response::setStatus(int stat) { + this->status = stat; +} + +int http_response::getStatus() { + return this->status; +} + +void http_response::setDescription(std::string desc) { + this->description = desc; +} +std::string http_response::getDescription() { + return this->description; +} + +void http_response::setHeaders(std::string key, std::string val) { + this->headers.insert(std::pair(key, val)); +} + +std::map::iterator http_response::getHeadersBegin() { + return this->headers.begin(); +} + +std::map::iterator http_response::getHeadersEnd() { + return this->headers.end(); +} +std::string http_response::getHeader(std::string key) { + std::map::iterator iter = this->headers.find(key); + if (iter != this->headers.end()) + return iter->second; + return ""; +} + +void http_response::setBodySize(size_t size) { + boost::interprocess::scoped_lock(this->TLock); + this->body_size = size; +} + +size_t http_response::getBodySize() { + boost::interprocess::scoped_lock(this->TLock); + return this->body_size; +} + +void http_response::setBody(std::string mybod) { + boost::interprocess::scoped_lock(this->TLock); + this->body += mybod; + this->progress += mybod.length(); +} + +void http_response::setBody(char c) { + boost::interprocess::scoped_lock(this->TLock); + this->body += c; + this->progress++; +} +std::string http_response::getBody() { + boost::interprocess::scoped_lock(this->TLock); + return this->body; + +} +size_t http_response::getProgress() { + boost::interprocess::scoped_lock(this->TLock); + return this->progress; } void http_response::flush() { /* nothing in the base class */ } - + std::string http_response::getURL() { boost::interprocess::scoped_lock(this->TLock); return this->url; @@ -133,7 +135,14 @@ void http_response::setURL(std::string url) { this->url = url; } +void http_response::clearBody() { + boost::interprocess::scoped_lock(this->TLock); + this->body.clear(); +} +void http_response::Completed() { + +} http_response_file::http_response_file() : http_response() { @@ -143,6 +152,7 @@ void http_response_file::reset() { this->filename = ""; this->CloseFile(); http_response::reset(); + std::cout << "Reset" << std::endl; } void http_response_file::setURL(std::string url) { @@ -158,6 +168,7 @@ void http_response_file::setURL(std::string url) { if (url_parts.size() >= 5) { this->filename = url_parts[4]; } + LogTrace() << "Filename set to:" << this->filename; this->CloseFile(); } @@ -179,29 +190,21 @@ bool http_response_file::OpenFile() { this->filepath = this->filename + "." + boost::lexical_cast(static_cast(i)); i++; } - this->file.clear(std::iostream::goodbit); - this->file.exceptions ( std::ifstream::failbit | std::ifstream::badbit ); - try { - std::cout << "about to open " << std::endl; - -// this->file.open(this->filepath, std::ios_base::binary | std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::app); - this->file.open(this->filepath); - } catch (std::ios_base::failure e) { - std::cout << "Exception opening/reading file" << e.what() << std::endl;; - } + LogTrace() << "About to open file: " << this->filepath; + this->file.open(this->filepath); if (this->file.is_open()) { - std::cout << "opened" << std::endl; this->opened = true; return true; } - std::cout << "not opened" << std::endl; + LogWarn() << "Could Not Open File: " << this->filepath; return false; } bool http_response_file::CloseFile() { this->opened = false; - this->filepath.clear(); - this->filename = ""; this->file.close(); return true; } +void http_response_file::Completed() { + this->CloseFile(); +} \ No newline at end of file diff --git a/xcode/HTTPClientProj.xcconfig b/xcode/HTTPClientProj.xcconfig new file mode 100644 index 0000000..959fcc2 --- /dev/null +++ b/xcode/HTTPClientProj.xcconfig @@ -0,0 +1,4 @@ +GCC_WARN_ABOUT_RETURN_TYPE = YES; +GCC_WARN_UNUSED_VARIABLE = YES; +GCC_INCREASE_PRECOMPILED_HEADER_SHARING = YES; +GCC_GENERATE_DEBUGGING_SYMBOLS = YES; diff --git a/xcode/HTTPClientTarget.xcconfig b/xcode/HTTPClientTarget.xcconfig new file mode 100644 index 0000000..285ba51 --- /dev/null +++ b/xcode/HTTPClientTarget.xcconfig @@ -0,0 +1,10 @@ +PRODUCT_NAME = libHTTPClient; +MACH_O_TYPE = mh_dylib; +DYLIB_COMPATIBILITY_VERSION = 1; +DYLIB_CURRENT_VERSION = 1; +GCC_PRECOMPILE_PREFIX_HEADER = YES; +GCC_PREFIX_HEADER = HTTPClient/HTTPClient-Prefix.pch; +GCC_ENABLE_CPP_EXCEPTIONS = YES; +GCC_ENABLE_CPP_RTTI = YES; +GCC_SYMBOLS_PRIVATE_EXTERN = YES; +