Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ithewei committed Aug 4, 2021
1 parent 2417e17 commit 647a3ee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions examples/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,19 @@ int main(int argc, char* argv[]) {
if (key_len && value_len) {
req.headers[std::string(key,key_len)] = std::string(value,value_len);
key_len = value_len = 0;
state = s_key;
}
state = s_key;
key = p+1;
}
else if (*p == ':') {
state = s_value;
value = p+1;
}
else {
state == s_key ? ++key_len : ++value_len;
if (state == s_key) {
if (++key_len == 1) key = p;
}
else {
if (++value_len == 1) value = p;
}
}
++p;
}
Expand Down Expand Up @@ -190,16 +193,19 @@ int main(int argc, char* argv[]) {
}
req.form[std::string(key,key_len)] = data;
key_len = value_len = 0;
state = s_key;
}
state = s_key;
key = p+1;
}
else if (*p == '=') {
state = s_value;
value = p+1;
}
else {
state == s_key ? ++key_len : ++value_len;
if (state == s_key) {
if (++key_len == 1) key = p;
}
else {
if (++value_len == 1) value = p;
}
}
++p;
}
Expand Down

0 comments on commit 647a3ee

Please sign in to comment.