tool_xattr: create the user.creator xattr attribute
This indicates that the file was created by curl which can help a user determine the origin of a file. Like the other attributes, this is only enabled with the --xattr option. Closes #15237
This commit is contained in:
parent
dfd36d3ee0
commit
954177b9da
@ -17,7 +17,7 @@ Example:
|
|||||||
# `--xattr`
|
# `--xattr`
|
||||||
|
|
||||||
When saving output to a file, tell curl to store file metadata in extended
|
When saving output to a file, tell curl to store file metadata in extended
|
||||||
file attributes. Currently, the URL is stored in the `xdg.origin.url`
|
file attributes. Currently, `curl` is stored in the `creator` attribute,
|
||||||
attribute and, for HTTP, the content type is stored in the `mime_type`
|
the URL is stored in the `xdg.origin.url` attribute and, for HTTP, the content
|
||||||
attribute. If the file system does not support extended attributes, a warning
|
type is stored in the `mime_type` attribute. If the file system does not
|
||||||
is issued.
|
support extended attributes, a warning is issued.
|
||||||
|
|||||||
@ -114,7 +114,7 @@ static int xattr(int fd,
|
|||||||
int fwrite_xattr(CURL *curl, const char *url, int fd)
|
int fwrite_xattr(CURL *curl, const char *url, int fd)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int err = 0;
|
int err = xattr(fd, "user.creator", "curl");
|
||||||
|
|
||||||
/* loop through all xattr-curlinfo pairs and abort on a set error */
|
/* loop through all xattr-curlinfo pairs and abort on a set error */
|
||||||
while(!err && mappings[i].attr) {
|
while(!err && mappings[i].attr) {
|
||||||
|
|||||||
@ -78,6 +78,7 @@ Accept: */*
|
|||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
<stdout mode="text">
|
<stdout mode="text">
|
||||||
|
user.creator => curl
|
||||||
user.mime_type => text/html
|
user.mime_type => text/html
|
||||||
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
||||||
</stdout>
|
</stdout>
|
||||||
|
|||||||
@ -55,6 +55,7 @@ Accept: */*
|
|||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
<stdout mode="text">
|
<stdout mode="text">
|
||||||
|
user.creator => curl
|
||||||
user.mime_type => fake/data
|
user.mime_type => fake/data
|
||||||
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
||||||
</stdout>
|
</stdout>
|
||||||
|
|||||||
@ -55,6 +55,7 @@ Accept: */*
|
|||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
<stdout mode="text">
|
<stdout mode="text">
|
||||||
|
user.creator => curl
|
||||||
user.mime_type => fake/data
|
user.mime_type => fake/data
|
||||||
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
user.xdg.origin.url => http://%HOSTIP:%HTTPPORT/%TESTNUMBER
|
||||||
</stdout>
|
</stdout>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user