repo: open-search-descriptor
action: blob
revision: 
path_from: httpd
revision_from: refs/heads/master:
path_to: 
revision_to: 
git.thebackupbox.net
open-search-descriptor
git clone git://git.thebackupbox.net/open-search-descriptor

blob of:

open-search-descriptor

/ httpd

blob_plain of this file

refs/heads/master:/httpd

 #!/usr/bin/env bash
 ### run this httpd if you want to have your web-browser send search requests to a search URIs
 ### that you can then handle however you want

 ### when I was using ncat -klp 8069 it was hanging until uristart finished.
 if [ -z "$1" ];then
   socat tcp-listen:8069,fork exec:"$0 kgo"
   exit 1
 fi

 read REQUEST_METHOD REQUEST_PATH REQUEST_VERSION

 printf "HTTP/1.0 200 OK\r\n"
 printf "Connection: close\r\n"
 printf "Content-Type: text/html\r\n\r\n"
 printf ''
 query="$(printf "%s\n" "$REQUEST_PATH" | cut -d? -f2-)"
 if [ "$query" ];then
   uri="search:?${query}"
   ### uristart can be replaced with xdg-open I guess. you'll need to register the search uri-scheme with it first.
   ### make it run uri-search-handler
   nohup uristart "${uri}" 2>&1 >/dev/null &
 fi