repo: uritools
action: commit
revision: 
path_from: 
revision_from: b4d87508f550421c2f032b88295ce2d006e9a241:
path_to: 
revision_to: 
git.thebackupbox.net
uritools
git clone git://git.thebackupbox.net/uritools
commit b4d87508f550421c2f032b88295ce2d006e9a241
Author: epoch 
Date:   Mon Feb 24 01:48:52 2025 +0000

    added did, at, and about schemes to urititle

diff --git a/urititle b/urititle
index 80b45251c7750dbfa8e4bcb6b6153d8ee4656e8d..
index ..bf743ea90f158cee53cb6de0e9dbd9b58e73d3ed 100755
--- a/urititle
+++ b/urititle
@@ -43,7 +43,7 @@ http*)
     UA="Mozilla/5.0 (impersonator)"
 #  content_type="$(printf "HEAD %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | grep -i '^Content-Type: ' | head -n1 | cut '-d ' -f2 | cut '-d;' -f1 | tr -d '\r\n')"
 #    echo "waiting for a header in the first 10kb" >&2
-    a_header="$((curl -gA "$UA" -Lsi "$uri" || echo curl failed) | head -c 10000 | egrep -ai '^curl failed|^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')"
+    a_header="$((curl -kgA "$UA" -Lsi "$uri" || echo curl failed) | head -c 10000 | egrep -ai '^curl failed|^Location: |^Content-Type: ' | head -n1 | tr -d '\r\n')"
     if printf "%s\n" "${a_header}" | grep -i '^Content-Type: ' 2>&1 >/dev/null 2>&1;then
       content_type="$(printf '%s\n' "${a_header}" | cut '-d ' -f2- | cut '-d;' -f1)"
     fi
@@ -57,7 +57,7 @@ http*)
     if [ "${content_type}" = "text/html" -o "${content_type}" = "application/xhtml+xml" -o "${content_type}" = "" ];then
 #     echo "trying to find  in HTML" >&2
 #    title="$(printf "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n" "$path" "$domain" "$UA" | ncat -4 $SSL "$domain" "$port" | head -c 10000 | tr -d '\n' | tr '<' '\n' | grep -A 10 '^title>' | grep -B 10 '^\/title>' | cut '-d>' -f2)"
-      title="$(curl -A "$UA" -gsi "$uri" | head -c 1000000 | tr -d '\n' | tr '<' '\n' | grep -iA 10 '^title' | grep -iB 10 '^\/title>' | cut '-d>' -f2 | tr '\t' ' ' | sed 's/^ *//g' | sed 's/ *$//g' | grep .)"
+      title="$(curl -kA "$UA" -gsi "$uri" | head -c 1000000 | tr -d '\n' | tr '<' '\n' | grep -iA 10 '^title' | grep -iB 10 '^\/title>' | cut '-d>' -f2 | tr '\t' ' ' | sed 's/^ *//g' | sed 's/ *$//g' | grep .)"
       if [ "${content_type}" = "" ];then
         printf "WTF: header: %s\n" "${a_header}"
         printf "WARNING: NO CONTENT-TYPE RETURNED FROM SERVER. Assuming text/html. title: %s\n" "$title" | html_entities_decode
@@ -131,6 +131,20 @@ gopher)
     printf "title: don't know how to get title of non-1 gopher links"
   fi
   ;;
+did)
+  method="$(printf "%s\n" "$uri" | cut -d: -f2)"
+  case "$method" in
+  web)
+    did-web-resolve "$uri"
+    ;;
+  plc)
+    did-plc-resolve "$uri"
+    ;;
+  *)
+    printf 'unimplemented did method: %s\n' "$method"
+    ;;
+  esac
+  ;;
 urn)
   nid="$(printf "%s\n" "$uri" | cut -d: -f2)"
   nss="$(printf "%s\n" "$uri" | cut -d: -f3)"
@@ -161,7 +175,7 @@ ssh)
   if [ ! "$port" ];then
     port=22
   fi
-  printf "title: %s\n" "$(printf "" | nc "$domain" "$port" | head -n1)"
+  printf "title: %s\n" "$(printf '' | nc --no-shutdown "$domain" "$port" | head -n1)"
   ;;
 smtp)
   if [ ! "$port" ];then
@@ -194,6 +208,21 @@ ident)
   port="${port:-113}"
   printf '%s\r\n' "$path" | nc "$domain" "$port" || echo 'ident lookup failed. port closed.'
   ;;
+about)
+  printf '<%s>\n' "$path"
+  ;;
+at)
+  case "${domain}" in
+  *:*)
+    ### it is a DID in the authority
+    printf 'DIDs in authority section of at URIs is unhandled atm\n'
+    ;;
+  *)
+    atproto-handle-resolution "${domain}"
+    ;;
+  esac
+  ;;
 *)
   printf "DONT KNOW HOW TO GET TITLE FOR THIS URL: %s\n" "$uri"
+  ;;
 esac
</pre>
<p>-----END OF PAGE-----</p>

</main>
</body>

</html>