wikitools icon indicating copy to clipboard operation
wikitools copied to clipboard

GET requests

Open nberger-git opened this issue 9 years ago • 3 comments

A site maintainer asked if the requests for content could be sent as GET instead of POST, so I made a couple of minor changes in wikitools to support this.

In case you want to propagate something like this to the master, the patch files wrt the current package version are linked here: https://gist.github.com/nberger-git/7fa9bc527c21a11caba2

nberger-git avatar Sep 21 '15 17:09 nberger-git

An updated version of the api.py patch : https://gist.github.com/nberger-git/77f1d8091987eaa19c53 This has a fix to avoid 503 errors in GET mode, provided by @cariaso.

nberger-git avatar Sep 25 '15 07:09 nberger-git

What's the motivation for using GET instead of POST in some cases? I'm not sure the additional code complexity is worth the benefit.

mzmcbride avatar Jun 09 '16 00:06 mzmcbride

There are 2 major benefits.

#1. Server performance. GET operations can be cached with Varnish and similar tools, POST cannot. My site has dramatically more bot traffic than humans, and this makes a big difference.

This is consistent with RFC1945 https://tools.ietf.org/html/rfc1945#section-8 which explicitly states

Applications must not cache responses to a POST request because the application has no way of knowing that the server would return an equivalent response on some future request.

See also http://stackoverflow.com/a/3477374

#2. Logging/Diagnostics. GET params are easily visible in a standard log

184.1.2.3 - - [09/Jun/2016:01:08:31 +0000] "GET /api.php?inprop=protection%7Csubjectid&format=json&rvprop=content%7Cids%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Csize&rawcontinue=1&prop=revisions%7Cinfo&titles=Rs62033400&rvlimit=1&action=query HTTP/1.1" 200 642 "-" "MediaWiki::Gateway/1.1.0"

is much more useful than

113.1.2.3 - - [08/Jun/2016:02:21:28 +0000] "POST /api.php HTTP/1.1" 200 917 "-" "python-wikitools/1.4"

For apache, getting these sorts of details from a POST requires installing additional modules, and is discouraged except during brief, targeted debugging.

https://httpd.apache.org/docs/current/mod/mod_dumpio.html

One possible implementation is at

https://github.com/cariaso/wikitools/commit/6b805c905877f3cb2306f4dc910574e38c28a939

And I would be happy to make a pull request, or any requested changes.

On Jun 9, 2016 9:21 AM, "MZMcBride" [email protected] wrote:

What's the motivation for using GET instead of POST in some cases? I'm not sure the additional code complexity is worth the benefit.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/alexz-enwp/wikitools/issues/31#issuecomment-224769924, or mute the thread https://github.com/notifications/unsubscribe/AAHpkkmYrsSXP0p5-nSUD96tvIM6GbqSks5qJ1yMgaJpZM4GBDqs .

cariaso avatar Jun 09 '16 01:06 cariaso