Imported Upstream version 7.40.0
[platform/upstream/curl.git] / docs / libcurl / opts / CURLOPT_FOLLOWLOCATION.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at http://curl.haxx.se/docs/copyright.html.
13 .\" *
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .\"
23 .TH CURLOPT_FOLLOWLOCATION 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
24 .SH NAME
25 CURLOPT_FOLLOWLOCATION \- follow HTTP 3xx redirects
26 .SH SYNOPSIS
27 #include <curl/curl.h>
28
29 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_FOLLOWLOCATION, long enable);
30 .SH DESCRIPTION
31 A parameter set to 1 tells the library to follow any Location: header that the
32 server sends as part of a HTTP header in a 3xx response.
33
34 This means that libcurl will re-send the same request on the new location and
35 follow new Location: headers all the way until no more such headers are
36 returned. \fICURLOPT_MAXREDIRS(3)\fP can be used to limit the number of
37 redirects libcurl will follow.
38
39 libcurl can limit to what protocols it will automatically follow. The accepted
40 protocols are set with \fICURLOPT_REDIR_PROTOCOLS(3)\fP and it excludes the
41 FILE protocol by default.
42
43 For users who think the existing location following is too naive, too simple
44 or just lacks features, it is very easy to instead implement your own redirect
45 follow logic with the use of \fIcurl_easy_getinfo(3)\fP's
46 \fICURLINFO_REDIRECT_URL\fP option instead of using
47 \fICURLOPT_FOLLOWLOCATION(3)\fP.
48 .SH DEFAULT
49 0, disabled
50 .SH PROTOCOLS
51 HTTP(S)
52 .SH EXAMPLE
53 .nf
54 CURL *curl = curl_easy_init();
55 if(curl) {
56   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
57
58   /* example.com is redirected, so we tell libcurl to follow redirection */
59   curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
60
61   curl_easy_perform(curl);
62 }
63 .fi
64 .SH AVAILABILITY
65 Along with HTTP
66 .SH RETURN VALUE
67 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
68 .SH "SEE ALSO"
69 .BR CURLOPT_REDIR_PROTOCOLS "(3), " CURLOPT_PROTOCOLS "(3), "
70 .BR CURLOPT_POSTREDIR "(3), "