HttpChunkedSplitter.cpp 962 Bytes
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
xiongziliang committed
5
 *
xiongziliang committed
6 7 8
 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
xiongziliang committed
9
 */
10

xiongziliang committed
11
#include <string.h>
12 13 14 15
#include "HttpChunkedSplitter.h"

namespace mediakit{
    
16
const char *HttpChunkedSplitter::onSearchPacketTail(const char *data, size_t len) {
17 18 19 20 21 22 23
    auto pos = strstr(data,"\r\n");
    if(!pos){
        return nullptr;
    }
    return pos + 2;
}

24
void HttpChunkedSplitter::onRecvContent(const char *data, size_t len) {
25 26 27
    onRecvChunk(data,len - 2);
}

28
ssize_t HttpChunkedSplitter::onRecvHeader(const char *data, size_t len) {
29 30 31 32 33 34 35
    string str(data,len - 2);
    int ret;
    sscanf(str.data(),"%X",&ret);
    return ret + 2;
}

}//namespace mediakit