How to code a handler for  HTTP requests?
It seems CiviCRM takes the default page action, civicrm/contact/view/someaction?qstr seems to return the same as civicrm/contact/view?qstr


Civi's router uses a fallback search. (The wisdom of this can be debated elsewhere - I'm just reporting facts.) For example, if you request civicrm/foo/bar/baz, then it will look for the routes in this order:


civicrm/foo/bar/baz
civicrm/foo/bar
civicrm/foo
civicrm


The first matching route will handle the page-request.


  Or perhaps register a route for civicrm/contact/view/someaction


If I understand correctly, I believe this is what you want.

Since you mentioned civix, look at Create a Module Extension for instructions to "Add a basic web page". It describes the command civix generate:page &lt;ClassName&gt; &lt;web/path&gt;, which will generate scaffolding for a new route.

Aside: When I first read the title, I interpreted the question to mean "How code different handlers for (GET/POST/PUT/DELETE) HTTP requests?" In case that really is the question: Civi's router doesn't distinguish between HTTP verbs. You can just define one route and then use something like switch($_REQUEST['REQUEST_METHOD']).