AFNetworking源码分析 (3)--AFURLRequestSerialization

系列文章:

上文中我们分析了AF中关于网络下载,NSURLSessionDownloadTask的分析。
本章将开始分析Serialization中的一个核心类请求数据封装类--AFURLRequestSerialization

1.初始化requestSerializer

参考例子沿用(1)中的例子:

AFHTTPSessionManager *session = [AFHTTPSessionManager manager];
session.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html",@"application/json", @"text/json" ,@"text/javascript", nil];
session.responseSerializer = [AFHTTPResponseSerializer serializer];
[session GET:@"https://www.baidu.com"
  parameters:nil
    progress:nil
     success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
         NSLog(@"请求成功");
     } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
          NSLog(@"请求失败");
     }];

查看manager的调用栈我们在AFHTTPSessionManager的如下接口完成对全局
requestSerializer的初始化。

- (instancetype)initWithBaseURL:(NSURL *)url
           sessionConfiguration:(NSURLSessionConfiguration *)configuration
{
    ...
    self.requestSerializer = [AFHTTPRequestSerializer serializer];
    ...

    return self;
}

1.1 [AFHTTPRequestSerializer serializer]

// 1.指定数据的编码格式
self.stringEncoding = NSUTF8StringEncoding;

// 2.请求的头部信息字典
self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary];

// 3.设置头部中请求的自然语言列表
// Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
NSMutableArray *acceptLanguagesComponents = [NSMutableArray array];
[[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
    float q = 1.0f - (idx * 0.1f);
    [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]];
    *stop = q <= 0.5f;
}];
[self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"];

// 4.设置请求的UA
NSString *userAgent = nil;
userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleExecutableKey] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleIdentifierKey], [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"] ?: [[NSBundle mainBundle] infoDictionary][(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]];
if (userAgent) {
    if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) {
        NSMutableString *mutableUserAgent = [userAgent mutableCopy];
        if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) {
            userAgent = mutableUserAgent;
        }
    }
    [self setValue:userAgent forHTTPHeaderField:@"User-Agent"];
}

// HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil];

// 5.kvo的方式监听allowsCellularAccess,cachePolicy,HTTPShouldHandleCookies,HTTPShouldUsePipelining,networkServiceType,timeoutInterval的属性的变化
self.mutableObservedChangedKeyPaths = [NSMutableSet set];
for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
    if ([self respondsToSelector:NSSelectorFromString(keyPath)]) {
        [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:AFHTTPRequestSerializerObserverContext];
    }
}

举例当外部更改cachePolicy的值时,依次执行如下方法:

 // 1.必须调用willChangeValueForKey与didChangeValueForKey自己触发observeValueForKeyPath的调用,因为代码段2
- (void)setCachePolicy:(NSURLRequestCachePolicy)cachePolicy {
    [self willChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
    _cachePolicy = cachePolicy;
    [self didChangeValueForKey:NSStringFromSelector(@selector(cachePolicy))];
}

// 2.可以指定属性变化时observeValueForKeyPath是否自动执行,很显然这里监听的几个属性都是需要手动触发,这也就解释了1中的问题
+ (BOOL)automaticallyNotifiesObserversForKey:(NSString *)key {
    if ([AFHTTPRequestSerializerObservedKeyPaths() containsObject:key]) {
        return NO;
    }

    return [super automaticallyNotifiesObserversForKey:key];
}

// 3.监听上述kvo监听的几个属性值的变化,操作全局的变化的属性集合
- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(__unused id)object
                        change:(NSDictionary *)change
                       context:(void *)context
{
    if (context == AFHTTPRequestSerializerObserverContext) {
        if ([change[NSKeyValueChangeNewKey] isEqual:[NSNull null]]) {
            [self.mutableObservedChangedKeyPaths removeObject:keyPath];
        } else {
            [self.mutableObservedChangedKeyPaths addObject:keyPath];
        }
    }
}

2.根据requestSerializer初始化request

初始化request的代码如下:

NSError *serializationError = nil;
NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:method URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:&serializationError];

下面我们来具体分析具体的处理逻辑。

2.1 requestWithMethod:URLString:parameters:error:

// 1.初始化request的实例
NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url];
mutableRequest.HTTPMethod = method;

// 2.将requestSerializer 中的存储的请求策略的属性值赋值给re  quest
for (NSString *keyPath in AFHTTPRequestSerializerObservedKeyPaths()) {
    if ([self.mutableObservedChangedKeyPaths containsObject:keyPath]) {
        [mutableRequest setValue:[self valueForKeyPath:keyPath] forKey:keyPath];
    }
}

mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy];

2.2 requestBySerializingRequest:withParameters:error:

该接口是AFURLRequestSerialization 协议定义的接口,该协议同时实现NSObject,NSSecureCoding, NSCopying 三个协议用于实现基本的Object行为,安全编码,拷贝功能。下面我们会依次分析实现这个协议的三个类:AFHTTPRequestSerializer,AFJSONRequestSerializer,AFPropertyListRequestSerializer

2.2.1 AFHTTPRequestSerializer

- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
                               withParameters:(id)parameters
                                        error:(NSError *__autoreleasing *)error
{
    NSParameterAssert(request);
    
    // 1.遍历外部设置的httpRequestHeaders然后依次设置到mutableRequest中
    NSMutableURLRequest *mutableRequest = [request mutableCopy];

    [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) {
        if (![request valueForHTTPHeaderField:field]) {
            [mutableRequest setValue:value forHTTPHeaderField:field];
        }
    }];

   // 2.处理请求的参数
    NSString *query = nil;
    if (parameters) {
        // 2.1 如果外部自己实现参数的处理则直接获取外部处理数据
        if (self.queryStringSerialization) {
            NSError *serializationError;
            query = self.queryStringSerialization(request, parameters, &serializationError);

            if (serializationError) {
                if (error) {
                    *error = serializationError;
                }

                return nil;
            }
        } else {
            // 2.2 否则走默认的实现方式,这里递归的方式实现(下面会具体分析)
            switch (self.queryStringSerializationStyle) {
                case AFHTTPRequestQueryStringDefaultStyle:
                    query = AFQueryStringFromParameters(parameters);
                    break;
            }
        }
    }

    // 3.将parameters处理后的数据拼接到URL中还是设置到httpBody中,默认的`GET`, `HEAD`,`DELETE`是拼接到URL中,`POST`,`PUT`是设置到httpBody中
    if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) {
        if (query && query.length > 0) {
            mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]];
        }
    } else {
        // #2864: an empty string is a valid x-www-form-urlencoded payload
        if (!query) {
            query = @"";
        }
        if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) {
            [mutableRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
        }
        [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]];
    }

    return mutableRequest;
}
2.2.1.1 AFQueryStringFromParameters(NSDictionary *parameters)

源码注释很清楚,此处只写出核心思想:

  • 核心函数:AFQueryStringPairsFromKeyAndValue
  • 核心思想:递归的方式实现,针对NSDictionary,NSArray,NSSet 三种数据遍历处理,然后针对每个内部元素递归处理。
  • Model:AFQueryStringPair是临时存储key与value的实例类,其中有一个核心的函数AFPercentEscapedStringFromString
2.2.1.2 AFPercentEscapedStringFromString(NSString *string)
NSString * AFPercentEscapedStringFromString(NSString *string) {

    // 1.将部分分隔符与保留字排除在允许不编码的字符集内
    static NSString * const kAFCharactersGeneralDelimitersToEncode = @":#[]@"; // does not include "?" or "/" due to RFC 3986 - Section 3.4
    static NSString * const kAFCharactersSubDelimitersToEncode = @"!$&'()*+,;=";
    
    NSMutableCharacterSet * allowedCharacterSet = [[NSCharacterSet URLQueryAllowedCharacterSet] mutableCopy];
    [allowedCharacterSet removeCharactersInString:[kAFCharactersGeneralDelimitersToEncode stringByAppendingString:kAFCharactersSubDelimitersToEncode]];

    // FIXME: https://github.com/AFNetworking/AFNetworking/pull/3028
    // return [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];

    // 2.处理多字节字符的问题,我们平常书写的字符, 并不全部都是用唯一的一个16位字符来表示, 而是有一部分用两个16位字符来表示(表情字符)
    static NSUInteger const batchSize = 50;

    NSUInteger index = 0;
    NSMutableString *escaped = @"".mutableCopy;
   
    while (index < string.length) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wgnu"
        NSUInteger length = MIN(string.length - index, batchSize);
#pragma GCC diagnostic pop
        NSRange range = NSMakeRange(index, length);
        // 2.1 分段处理一个个完整的字符,然后再次拼接
        // To avoid breaking up character sequences such as 👴🏻👮🏽
        range = [string rangeOfComposedCharacterSequencesForRange:range];

        NSString *substring = [string substringWithRange:range];
        NSString *encoded = [substring stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet];
        [escaped appendString:encoded];

        index += range.length;
    }

    return escaped;
}

2.2.2 AFJSONRequestSerializer,AFPropertyListRequestSerializer

都是AFHTTPRequestSerializer的派生类,一般针对POST,PUT的网络请求,对请求的字典参数分别使用NSJSONSerializationNSPropertyListSerialization 序列化。

/**
 `AFJSONRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSJSONSerialization`, setting the `Content-Type` of the encoded request to `application/json`.
 */
@interface AFJSONRequestSerializer : AFHTTPRequestSerializer

/**
 `AFPropertyListRequestSerializer` is a subclass of `AFHTTPRequestSerializer` that encodes parameters as JSON using `NSPropertyListSerializer`, setting the `Content-Type` of the encoded request to `application/x-plist`.
 */
@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer

2.3 multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:

我们先看看接口注释:

Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` 
HTTP body, using the specified parameters and multipart form data block。
Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream.

显而易见这里是上传数据的接口。

2.3.1 图片上传的例子

首先利用ImageServer,搭建一个本地的图片服务器供iOS上传接口测试使用。下面是iOS具体上传的例子:

- (void)uploadImage{
    self.session = [AFHTTPSessionManager manager];
    _session.responseSerializer = [AFJSONResponseSerializer serializer];
    _session.responseSerializer.acceptableContentTypes = nil;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"github_1"
                                           ofType:@"jpeg"];
    NSData *data = [NSData dataWithContentsOfFile:path];
    NSString *url = @"http://192.168.2.12:8888/";
    NSMutableURLRequest *request = [_session.requestSerializer
                                    multipartFormRequestWithMethod:@"POST"
                                    URLString:url
                                    parameters:nil
                                    constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
                                        [formData appendPartWithFileData:data
                                                                    name:@"file"
                                                                fileName:@"github_1.jpeg"
                                                                mimeType:@"application/octet-stream"];
                                    }
                                    
                                    error:nil];
    request.timeoutInterval = 10;
    
    NSURLSessionUploadTask *uploadTask = [_session uploadTaskWithRequest:request fromData:nil progress:nil completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
        if (error == nil) {
            NSLog(@"文件上传成功");
        } else {
            NSLog(@"文件上传失败 -> %@",error);
        }
    }];
    [uploadTask resume];
}

2.3.2 具体的实现分析

我们先使用Charles抓包看一下请求的格式:

POST / HTTP/1.1
Host    127.0.0.1:8989
Content-Type    multipart/form-data; boundary=Boundary+0544FD8CDFD7A4C1
Connection  keep-alive
Accept  */*
User-Agent  InterView/1.0 (iPhone; iOS 10.0; Scale/2.00)
Accept-Language en;q=1, zh-Hans-US;q=0.9
Content-Length  11027
Accept-Encoding gzip, deflate


--Boundary+0544FD8CDFD7A4C1
Content-Disposition: form-data; name="file"; filename="github_1.jpeg"
Content-Type: application/octet-stream

// 二进制数据

--Boundary+0544FD8CDFD7A4C1--

  • Content-Type必须是这样的Content-Type: multipart/form-data; boundary=${bound},类似0544FD8CDFD7A4C1是随机数生成的。
  • 每一部分以$--{bound}开始,以--{bound}--结束。

下面我们针对代码具体分析。

2.3.2.1 AFHTTPRequestSerializer multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:
// 1.初始化一个待提交的multipart的实例
__block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding];

// 2.针对请求的参数依次拼接到请求的formData中
if (parameters) {
    for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) {
        NSData *data = nil;
        if ([pair.value isKindOfClass:[NSData class]]) {
            data = pair.value;
        } else if ([pair.value isEqual:[NSNull null]]) {
            data = [NSData data];
        } else {
            data = [[pair.value description] dataUsingEncoding:self.stringEncoding];
        }

        if (data) {
            [formData appendPartWithFormData:data name:[pair.field description]];
        }
    }
}

// 3.外部如果需要对提交的表单做操作可以实现该block,完成自定义的操作
if (block) {
    block(formData);
}

// 4.将整理的表单数据配置到请求的实例中
return [formData requestByFinalizingMultipartFormData];
2.3.2.2 AFStreamingMultipartFormData initWithURLRequest:stringEncoding:
self.request = urlRequest;
self.stringEncoding = encoding;

// 1.这里说明了是随机数字的16进制字符拼接(见下接口实现)
self.boundary = AFCreateMultipartFormBoundary();

// 2.初始化数据流的实例,后续会设置到请求request中
self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding];


static NSString * AFCreateMultipartFormBoundary() {
    return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()];
}
2.3.2.3 AFStreamingMultipartFormData requestByFinalizingMultipartFormData
- (NSMutableURLRequest *)requestByFinalizingMultipartFormData {
    if ([self.bodyStream isEmpty]) {
        return self.request;
    }

    // 1.对bodyStream中的HTTPBodyParts集合中的每一个AFHTTPBodyPart做hasInitialBoundary,hasFinalBoundary的标识,以便区分设置2.2.2开始部分请求数据。
    
    [self.bodyStream setInitialAndFinalBoundaries];
    
    // 2.将数据流绑定到请求的request实例中
    // 官方描述:The input stream should be unopened and the receiver will take over as the stream’s delegate
    [self.request setHTTPBodyStream:self.bodyStream];

    // 3.设置请求的头信息
    [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"];
    [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"];

    return self.request;
}
2.3.2.4 read:maxLength:

[self.request setHTTPBodyStream:self.bodyStream];设置后,请求任务开始执行,下面的方法就会被回调:

- (NSInteger)read:(uint8_t *)buffer
        maxLength:(NSUInteger)length
{
    if ([self streamStatus] == NSStreamStatusClosed) {
        return 0;
    }

    NSInteger totalNumberOfBytesRead = 0;
    
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu"

    // 1.遍历的方式读取么一个AFHTTPBodyPart中的数据
    while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) {
        if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) {
            // 2.读取到最后一个为nil时跳出循环
            if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) {
                break;
            }
        } else {
           // 3.读取当前的AFHTTPBodyPart中的收
            NSUInteger maxLength = MIN(length, self.numberOfBytesInPacket) - (NSUInteger)totalNumberOfBytesRead;
            NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength];
            if (numberOfBytesRead == -1) {
                self.streamError = self.currentHTTPBodyPart.inputStream.streamError;
                break;
            } else {
                totalNumberOfBytesRead += numberOfBytesRead;

                if (self.delay > 0.0f) {
                    [NSThread sleepForTimeInterval:self.delay];
                }
            }
        }
    }
#pragma clang diagnostic pop

    return totalNumberOfBytesRead;
}
2.3.2.5 AFHTTPBodyPart read:maxLength:
// 四个状态的改变,表示依次解析顶部分割标识,headers数据,二进制数据bodyData,底部分割标识
- (NSInteger)read:(uint8_t *)buffer
        maxLength:(NSUInteger)length
{
    NSInteger totalNumberOfBytesRead = 0;

    if (_phase == AFEncapsulationBoundaryPhase) {
       
    }

    if (_phase == AFHeaderPhase) {
    
    }

    if (_phase == AFBodyPhase) {
        
    }

    if (_phase == AFFinalBoundaryPhase) {
       
    }

    return totalNumberOfBytesRead;
}
- (NSInteger)readData:(NSData *)data
           intoBuffer:(uint8_t *)buffer
            maxLength:(NSUInteger)length
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu"
    NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length));
    [data getBytes:buffer range:range];
#pragma clang diagnostic pop

    _phaseReadOffset += range.length;
    
    // 1.当_phaseReadOffset < [data length] 标识数据已经读取完毕
    if (((NSUInteger)_phaseReadOffset) >= [data length]) {
        // 2.存在有数据未读取完成,继续改变状态读取相应的信息
        [self transitionToNextPhase];
    }

    return (NSInteger)range.length;
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,014评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,796评论 3 386
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,484评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,830评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,946评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,114评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,182评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,927评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,369评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,678评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,832评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,533评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,166评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,885评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,128评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,659评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,738评论 2 351

推荐阅读更多精彩内容

  • #import//网络请求的根路径 #define rootPath @"http://jufeng.veyd.c...
    高乔人阅读 919评论 0 1
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,639评论 18 139
  • AFNetworking2.0源码解析<一> AFNetworking2.0源码解析<二>-- 构建普通请求: 格...
    钱嘘嘘阅读 1,769评论 0 4
  • //需要AFN //.h //AFNetworking + (void)post:(NSString *)url ...
    CHADHEA阅读 760评论 0 0
  • 一.前言 最近重构项目,遇到了很多问题,也从中总结出了几点经验,这里先讲一讲网络工具类的封装,网络请求是前端和后台...
    laitys阅读 4,020评论 13 30