From: Daniel Stenberg Date: Tue, 9 Jan 2024 22:47:01 +0000 (+0100) Subject: examples/range.c: add X-Git-Tag: curl-8_6_0~104 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5d75bcd2eaa9b10b843dfe6d194a10524de79d46;p=thirdparty%2Fcurl.git examples/range.c: add Closes #12671 --- diff --git a/docs/examples/Makefile.inc b/docs/examples/Makefile.inc index baaedf9755..71dac0bf43 100644 --- a/docs/examples/Makefile.inc +++ b/docs/examples/Makefile.inc @@ -109,6 +109,7 @@ check_PROGRAMS = \ postit2-formadd \ progressfunc \ protofeats \ + range \ resolve \ rtsp-options \ sendrecv \ diff --git a/docs/examples/range.c b/docs/examples/range.c new file mode 100644 index 0000000000..1a93f3676a --- /dev/null +++ b/docs/examples/range.c @@ -0,0 +1,45 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://curl.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + * SPDX-License-Identifier: curl + * + ***************************************************************************/ +/* + * GET a range only of a HTTP resource + * + */ +#include + +int main(void) +{ + CURL *curl; + CURLcode res = CURLE_OK; + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://curl.se/"); + curl_easy_setopt(curl, CURLOPT_RANGE, "200-999"); + + res = curl_easy_perform(curl); + curl_easy_cleanup(curl); + } + + return (int)res; +}