]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/visionect/visionect.factor
mason: move alignment to mason.css, right align but-last columns in table body
[factor.git] / extra / visionect / visionect.factor
index 24ee5983c0b9e33ebe4277cf552e92ad8fb3eda2..61ba4cee47f4ad3899d6b3ef4ea5e17a18e355e8 100644 (file)
@@ -1,15 +1,15 @@
 ! Copyright (C) 2020 John Benediktsson
-! See http://factorcode.org/license.txt for BSD license
+! See https://factorcode.org/license.txt for BSD license
 
 USING: accessors assocs base64 calendar calendar.format
-checksums.hmac checksums.sha combinators combinators.smart
-formatting fry http http.client json.reader json.writer kernel
-locals make math.parser namespaces random sequences ;
+checksums.hmac checksums.sha combinators.smart formatting
+hex-strings http http.client json kernel make namespaces random
+sequences splitting ;
 
 IN: visionect
 
 SYMBOL: visionect-base-url
-visionect-base-url [ "http://localhost:8081" ] initialize
+visionect-base-url [ "https://localhost:8081" ] initialize
 
 SYMBOL: visionect-api-key
 
@@ -24,13 +24,13 @@ SYMBOL: visionect-api-secret
         [ "content-type" header ]
         [ "date" header ]
         [ url>> path>> ]
-    } cleave>array "\n" join
+    } cleave>array join-lines
     visionect-api-secret get sha-256 hmac-bytes >base64
     visionect-api-key get ":" rot 3append ;
 
 : set-visionect-headers ( request -- request )
-    now timestamp>http-string "date" set-header
-    dup visionect-authorization "authorization" set-header ;
+    now timestamp>http-string "Date" set-header
+    dup visionect-authorization "Authorization" set-header ;
 
 : visionect-request ( request -- data )
     set-visionect-headers http-request nip ;
@@ -49,7 +49,8 @@ SYMBOL: visionect-api-secret
 
 : visionect-post ( post-data path -- data )
     visionect-url <post-request>
-    dup post-data>> content-type>> "content-type" set-header
+    dup post-data>> dup post-data?
+    [ content-type>> "Content-Type" set-header ] [ drop ] if
     visionect-request ;
 
 PRIVATE>
@@ -179,11 +180,11 @@ PRIVATE>
     "multipart/form-data; boundary=\"" boundary "\"" 3append :> content-type
     content-type <post-data>
     [
-        "--" % boundary % "\n" %
-        "Content-Disposition: form-data; name=\"image\"; filename=\"image.png\"\n" %
-        "Content-Type: image/png\n" %
-        "\n" %
-        png-data % "\n" %
-        "--" % boundary % "--\n" %
+        "--" % boundary % "\r\n" %
+        "Content-Disposition: form-data; name=\"image\"; filename=\"image.png\"\r\n" %
+        "Content-Type: image/png\r\n" %
+        "\r\n" %
+        png-data % "\r\n" %
+        "--" % boundary % "--\r\n" %
     ] B{ } make >>data
     "/backend/" uuid append visionect-post drop ;