Skip to content

Support of --method, --body-data and --body-file#6

Open
stokito wants to merge 3 commits intoopenwrt:masterfrom
stokito:post_body_method
Open

Support of --method, --body-data and --body-file#6
stokito wants to merge 3 commits intoopenwrt:masterfrom
stokito:post_body_method

Conversation

@stokito
Copy link

@stokito stokito commented Jul 13, 2024

The PR allows to set a custom method e.g. PUT, DELETE but only that supported by the request_type enum.
This opens a way to use most of modern REST APIs:

wget -O - -q \
--method=DELETE \
http://api.example.com/

You may send a body:

wget -O - -q \
--method=PUT \
--body-data='{"id": 42}' \
--header='Content-Type: application/json' \
http://api.example.com/

@dhewg @dangowrt @mans0n @efahl @ynezz please review

stokito and others added 3 commits July 13, 2024 12:48
The var means that ether --post-data or --post-file was set.

Remove duplicated code to set the Content-Type header.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
In GNU wget the --spider first issues a HEAD request, then if HEAD fails, issues a GET request.
In uclient, only a GET request is sent.
The patch changes GET to HEAD e.g. get the file size without downloading it first.

This is still not totally compatible with GNU wget because it does not retry with GET if HEAD fails.
Someone may use the --spider to call a GET only API, so they may be affected.
But this is incorrect usage while others may expect that the spider uses HEAD and don't expect a download.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
The --method allows executing PUT, DELETE, OPTIONS, HEAD e.g.:

    wget -O - -q \
    --method=PUT \
    --body-data='{"id": 42}' \
    --header='Content-Type: application/json' \
    http://api.example.com/

To avoid clashes with the --post-data/file options,
the separate --body-data/file must be used.
They are stored to the same post_data and post_data vars.
Mutual usage of the options is not allowed, same as in GNU wget.

Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
@stokito
Copy link
Author

stokito commented Sep 5, 2024

@dhewg @dangowrt @mans0n @efahl @ynezz please review if you'll have a minute

@efahl
Copy link
Contributor

efahl commented Sep 5, 2024

Looks good to me! I like how it cleans up the Content-Type header logic.

I noticed that no_output relies on implicit initialization, which bugs me, but it's been like that for 9 years, so...

@stokito
Copy link
Author

stokito commented Sep 5, 2024

@Neustradamus
Copy link

@dangowrt, @nbd168: What do you think?

@stokito
Copy link
Author

stokito commented Oct 17, 2025

friendly remind on this

@efahl
Copy link
Contributor

efahl commented Oct 17, 2025

Yes, I think it would be nice to have this and give the small flash devices some capabilities normally solved by installing the 400k, 10x-bigger wget-ssl package.

@dangowrt Got any bandwidth for this?

@stokito
Copy link
Author

stokito commented Jan 7, 2026

@dangowrt could you please merge the PR?

@stokito
Copy link
Author

stokito commented Jan 31, 2026

Dear @nbd168 maybe you'll have a minute to review and merge the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants