Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
opt
cpr
opt
curl
lib
http_chunks.h
Go to the documentation of this file.
1
#ifndef HEADER_CURL_HTTP_CHUNKS_H
2
#define HEADER_CURL_HTTP_CHUNKS_H
3
/***************************************************************************
4
* _ _ ____ _
5
* Project ___| | | | _ \| |
6
* / __| | | | |_) | |
7
* | (__| |_| | _ <| |___
8
* \___|\___/|_| \_\_____|
9
*
10
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
11
*
12
* This software is licensed as described in the file COPYING, which
13
* you should have received as part of this distribution. The terms
14
* are also available at https://curl.haxx.se/docs/copyright.html.
15
*
16
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
17
* copies of the Software, and permit persons to whom the Software is
18
* furnished to do so, under the terms of the COPYING file.
19
*
20
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21
* KIND, either express or implied.
22
*
23
***************************************************************************/
24
/*
25
* The longest possible hexadecimal number we support in a chunked transfer.
26
* Weird enough, RFC2616 doesn't set a maximum size! Since we use strtoul()
27
* to convert it, we "only" support 2^32 bytes chunk data.
28
*/
29
#define MAXNUM_SIZE 16
30
31
typedef
enum
{
32
/* await and buffer all hexadecimal digits until we get one that isn't a
33
hexadecimal digit. When done, we go CHUNK_LF */
34
CHUNK_HEX
,
35
36
/* wait for LF, ignore all else */
37
CHUNK_LF
,
38
39
/* We eat the amount of data specified. When done, we move on to the
40
POST_CR state. */
41
CHUNK_DATA
,
42
43
/* POSTLF should get a CR and then a LF and nothing else, then move back to
44
HEX as the CRLF combination marks the end of a chunk. A missing CR is no
45
big deal. */
46
CHUNK_POSTLF
,
47
48
/* Used to mark that we're out of the game. NOTE: that there's a 'dataleft'
49
field in the struct that will tell how many bytes that were not passed to
50
the client in the end of the last buffer! */
51
CHUNK_STOP
,
52
53
/* At this point optional trailer headers can be found, unless the next line
54
is CRLF */
55
CHUNK_TRAILER
,
56
57
/* A trailer CR has been found - next state is CHUNK_TRAILER_POSTCR.
58
Next char must be a LF */
59
CHUNK_TRAILER_CR
,
60
61
/* A trailer LF must be found now, otherwise CHUNKE_BAD_CHUNK will be
62
signalled If this is an empty trailer CHUNKE_STOP will be signalled.
63
Otherwise the trailer will be broadcasted via Curl_client_write() and the
64
next state will be CHUNK_TRAILER */
65
CHUNK_TRAILER_POSTCR
66
}
ChunkyState
;
67
68
typedef
enum
{
69
CHUNKE_STOP
= -1,
70
CHUNKE_OK
= 0,
71
CHUNKE_TOO_LONG_HEX
= 1,
72
CHUNKE_ILLEGAL_HEX
,
73
CHUNKE_BAD_CHUNK
,
74
CHUNKE_WRITE_ERROR
,
75
CHUNKE_BAD_ENCODING
,
76
CHUNKE_OUT_OF_MEMORY
,
77
CHUNKE_LAST
78
}
CHUNKcode
;
79
80
const
char
*
Curl_chunked_strerror
(
CHUNKcode
code);
81
82
struct
Curl_chunker
{
83
char
hexbuffer
[
MAXNUM_SIZE
+ 1];
84
int
hexindex
;
85
ChunkyState
state
;
86
curl_off_t
datasize
;
87
size_t
dataleft
;
/* untouched data amount at the end of the last buffer */
88
};
89
90
#endif
/* HEADER_CURL_HTTP_CHUNKS_H */
91
Curl_chunker::state
ChunkyState state
Definition:
http_chunks.h:85
CHUNKE_OUT_OF_MEMORY
Definition:
http_chunks.h:76
Curl_chunker
Definition:
http_chunks.h:82
CHUNKE_OK
Definition:
http_chunks.h:70
CHUNKE_ILLEGAL_HEX
Definition:
http_chunks.h:72
Curl_chunker::hexbuffer
char hexbuffer[MAXNUM_SIZE+1]
Definition:
http_chunks.h:83
CHUNK_DATA
Definition:
http_chunks.h:41
CHUNK_TRAILER_CR
Definition:
http_chunks.h:59
ChunkyState
ChunkyState
Definition:
http_chunks.h:31
CHUNK_STOP
Definition:
http_chunks.h:51
CHUNKE_STOP
Definition:
http_chunks.h:69
CHUNKE_BAD_ENCODING
Definition:
http_chunks.h:75
CHUNKE_TOO_LONG_HEX
Definition:
http_chunks.h:71
CHUNK_TRAILER
Definition:
http_chunks.h:55
CHUNK_HEX
Definition:
http_chunks.h:34
CHUNKE_BAD_CHUNK
Definition:
http_chunks.h:73
Curl_chunker::dataleft
size_t dataleft
Definition:
http_chunks.h:87
CHUNKE_WRITE_ERROR
Definition:
http_chunks.h:74
CHUNKcode
CHUNKcode
Definition:
http_chunks.h:68
curl_off_t
CURL_TYPEOF_CURL_OFF_T curl_off_t
Definition:
system.h:420
Curl_chunked_strerror
const char * Curl_chunked_strerror(CHUNKcode code)
Definition:
http_chunks.c:359
CHUNKE_LAST
Definition:
http_chunks.h:77
CHUNK_LF
Definition:
http_chunks.h:37
CHUNK_POSTLF
Definition:
http_chunks.h:46
CHUNK_TRAILER_POSTCR
Definition:
http_chunks.h:65
MAXNUM_SIZE
#define MAXNUM_SIZE
Definition:
http_chunks.h:29
Curl_chunker::hexindex
int hexindex
Definition:
http_chunks.h:84
Curl_chunker::datasize
curl_off_t datasize
Definition:
http_chunks.h:86
rc_tagdetect_client
Author(s): Monika Florek-Jasinska
, Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:15