Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-05-30
16:23 • Closed ticket [15e4bd83c2]: http::geturl: Documentation discrepancy on -query {}... artifact: d29107612a user: kjnash
2022-05-13
02:58 • Pending ticket [15e4bd83c2]. artifact: 3f6f4c7823 user: kjnash
2022-05-12
12:59 • Ticket [15e4bd83c2]: 4 changes artifact: 7e441e04e8 user: oehhar
01:41 • Ticket [15e4bd83c2]: 3 changes artifact: cdd2b8588c user: kjnash
01:36 • Ticket [15e4bd83c2]: 3 changes artifact: a99b2800b6 user: kjnash
2022-05-10
22:05 • Ticket [6afa947d1a] http::geturl : Missing Content-Length header for POST reques... artifact: 70a273226d user: kjnash
19:29 • Ticket [15e4bd83c2] http::geturl: Documentation discrepancy on -query {} sta... artifact: a343f96571 user: kjnash
2021-10-04
16:32 • New ticket [15e4bd83c2]. artifact: d07780f83b user: oehhar

http::geturl: Documentation discrepancy on -query {}

Closed / Fixed15e4bd83c28d0a817bf30e06071c90fe1e6db534Created 5 years agoUpdated 5 years ago
Descriptionwiki2021-10-04 16:32:16
Sorry for the following detail:
http::geturl $URL -query {}

sends a get request and not a post request.

The documentation of 8.6.11 is: https://www.tcl-lang.org/man/tcl8.6/TclCmd/http.htm#M29

-query query
    This flag causes ::http::geturl to do a POST request...

In this corner case, it does not. It sends a get request.

I suppose, we can not change the behaviour. It might be beneficial to change the wording to say that an empty query sends a get request.

Any comments welcome.

Best regards, Harald

Note: for my personal use, it would be handy to send a post request with empty payload.

kjnashwiki2022-05-10 19:29:25

Hi Harald,

I've just looked at RFC 7230-3 and I cannot see anything that forbids a POST request with no message body. However, it is an unusual case: do you use custom request headers to modify the state of the server?

The behaviour of http::geturl could be changed, but this is a change of API that might break some existing code, and would require an increase in the major version of the http package.

Fortunately, you can use the existing http::geturl to send POST with an empty body by using the options "-method POST -headers {Content-Length 0}".

    -method type
        Force the HTTP request method to type. ::http::geturl will auto-select GET, POST or HEAD based on other options, but this option enables choices like PUT and DELETE for webdav support.

I will modify the man page http(n) to state that the value for -query must be non-empty to cause the POST method.

Best wishes,

Keith.

kjnashwiki2022-05-12 01:36:19

Documentation http(n) changed:

For -query, to say that an empty query does not sent a POST, see commit [1b15e55938a9b2fc].

For -method, to describe the case of a POST with no request-body, see commit [751f947bc87f6b2f].

kjnash Ticket [15e4bd83c2]: 3 changes [History diff]2022-05-12 01:41:47
oehharwiki2022-05-12 12:59:55

Great, I appreciate ! My use-case was the testing of the TCLWS package and what it does, if there is no data.

Thanks, Harald

kjnash Pending ticket [15e4bd83c2]. [History diff]2022-05-13 02:58:39
kjnash Closed ticket [15e4bd83c2]. [History diff]2022-05-30 16:23:42
Log in (anonymous is fine) to add a comment.