http: add support to read and store the referrer header

- add CURLINFO_REFERER libcurl option
- add --write-out '%{referer}' command-line option
- extend --xattr command-line option to fill user.xdg.referrer.url extended
  attribute with the referrer (if there was any)

Closes #6591
This commit is contained in:
Viktor Szakats 2021-02-19 13:57:19 +00:00
parent 70472a44de
commit 44872aefc2
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
15 changed files with 35 additions and 11 deletions

View file

@ -93,6 +93,9 @@ When an HTTP request was made without --location to follow redirects (or when
--max-redir is met), this variable will show the actual URL a redirect
\fIwould\fP have gone to. (Added in 7.18.2)
.TP
.B referer
The Referer: header, if there was any. (Added in 7.76.0)
.TP
.B remote_ip
The remote IP address of the most recently done connection - can be either
IPv4 or IPv6 (Added in 7.29.0)

View file

@ -43,6 +43,7 @@ check_PROGRAMS = \
getinfo \
getinmemory \
getredirect \
getreferrer \
http-post \
http2-download \
http2-pushinmemory \

View file

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@ -50,6 +50,9 @@ See \fICURLINFO_EFFECTIVE_URL(3)\fP
.IP CURLINFO_RESPONSE_CODE
Last received response code.
See \fICURLINFO_RESPONSE_CODE(3)\fP
.IP CURLINFO_REFERER
Referrer header.
See \fICURLINFO_REFERER(3)\fP
.IP CURLINFO_HTTP_CONNECTCODE
Last proxy CONNECT response code.
See \fICURLINFO_HTTP_CONNECTCODE(3)\fP

View file

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
@ -58,3 +58,4 @@ Returns CURLE_OK if HTTP support is enabled, CURLE_UNKNOWN_OPTION if not, or
CURLE_OUT_OF_MEMORY if there was insufficient heap space.
.SH "SEE ALSO"
.BR CURLOPT_USERAGENT "(3), " CURLOPT_HTTPHEADER "(3), "
.BR CURLINFO_REFERER "(3), "

View file

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@ -64,6 +64,7 @@ man_MANS = \
CURLINFO_REDIRECT_TIME.3 \
CURLINFO_REDIRECT_TIME_T.3 \
CURLINFO_REDIRECT_URL.3 \
CURLINFO_REFERER.3 \
CURLINFO_REQUEST_SIZE.3 \
CURLINFO_RESPONSE_CODE.3 \
CURLINFO_RETRY_AFTER.3 \

View file

@ -271,6 +271,7 @@ CURLINFO_REDIRECT_COUNT 7.9.7
CURLINFO_REDIRECT_TIME 7.9.7
CURLINFO_REDIRECT_TIME_T 7.61.0
CURLINFO_REDIRECT_URL 7.18.2
CURLINFO_REFERER 7.76.0
CURLINFO_REQUEST_SIZE 7.4.1
CURLINFO_RESPONSE_CODE 7.10.8
CURLINFO_RETRY_AFTER 7.66.0