初始化提交
This commit is contained in:
13
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.h
vendored
Normal file
13
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.h
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "HTTPResponse.h"
|
||||
|
||||
|
||||
@interface HTTPDataResponse : NSObject <HTTPResponse>
|
||||
{
|
||||
NSUInteger offset;
|
||||
NSData *data;
|
||||
}
|
||||
|
||||
- (id)initWithData:(NSData *)data;
|
||||
|
||||
@end
|
||||
83
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.m
vendored
Normal file
83
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPDataResponse.m
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#import "HTTPDataResponse.h"
|
||||
#import "HTTPLogging.h"
|
||||
|
||||
#if ! __has_feature(objc_arc)
|
||||
#warning This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
#pragma clang diagnostic ignored "-Wcast-qual"
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
|
||||
// Log levels : off, error, warn, info, verbose
|
||||
// Other flags: trace
|
||||
static const int httpLogLevel = HTTP_LOG_LEVEL_OFF; // | HTTP_LOG_FLAG_TRACE;
|
||||
|
||||
|
||||
@implementation HTTPDataResponse
|
||||
|
||||
- (id)initWithData:(NSData *)dataParam
|
||||
{
|
||||
if((self = [super init]))
|
||||
{
|
||||
HTTPLogTrace();
|
||||
|
||||
offset = 0;
|
||||
data = dataParam;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
HTTPLogTrace();
|
||||
|
||||
}
|
||||
|
||||
- (UInt64)contentLength
|
||||
{
|
||||
UInt64 result = (UInt64)[data length];
|
||||
|
||||
HTTPLogTrace2(@"%@[%p]: contentLength - %llu", THIS_FILE, self, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (UInt64)offset
|
||||
{
|
||||
HTTPLogTrace();
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
- (void)setOffset:(UInt64)offsetParam
|
||||
{
|
||||
HTTPLogTrace2(@"%@[%p]: setOffset:%lu", THIS_FILE, self, (unsigned long)offset);
|
||||
|
||||
offset = (NSUInteger)offsetParam;
|
||||
}
|
||||
|
||||
- (NSData *)readDataOfLength:(NSUInteger)lengthParameter
|
||||
{
|
||||
HTTPLogTrace2(@"%@[%p]: readDataOfLength:%lu", THIS_FILE, self, (unsigned long)lengthParameter);
|
||||
|
||||
NSUInteger remaining = [data length] - offset;
|
||||
NSUInteger length = lengthParameter < remaining ? lengthParameter : remaining;
|
||||
|
||||
void *bytes = (void *)(((char*)[data bytes]) + offset);
|
||||
|
||||
offset += length;
|
||||
|
||||
return [NSData dataWithBytesNoCopy:bytes length:length freeWhenDone:NO];
|
||||
}
|
||||
|
||||
- (BOOL)isDone
|
||||
{
|
||||
BOOL result = (offset == [data length]);
|
||||
|
||||
HTTPLogTrace2(@"%@[%p]: isDone - %@", THIS_FILE, self, (result ? @"YES" : @"NO"));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
9
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPErrorResponse.h
vendored
Normal file
9
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPErrorResponse.h
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#import "HTTPResponse.h"
|
||||
|
||||
@interface HTTPErrorResponse : NSObject <HTTPResponse> {
|
||||
NSInteger _status;
|
||||
}
|
||||
|
||||
- (id)initWithErrorCode:(int)httpErrorCode;
|
||||
|
||||
@end
|
||||
40
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPErrorResponse.m
vendored
Normal file
40
WebDriverAgentLib/Vendor/CocoaHTTPServer/Responses/HTTPErrorResponse.m
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#import "HTTPErrorResponse.h"
|
||||
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
|
||||
@implementation HTTPErrorResponse
|
||||
|
||||
-(id)initWithErrorCode:(int)httpErrorCode
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_status = httpErrorCode;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UInt64) contentLength {
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (UInt64) offset {
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void)setOffset:(UInt64)offset {
|
||||
;
|
||||
}
|
||||
|
||||
- (NSData*) readDataOfLength:(NSUInteger)length {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) isDone {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSInteger) status {
|
||||
return _status;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user