From 9e4adede5fb0c76925818119202b98d9d43454c2 Mon Sep 17 00:00:00 2001 From: Alex Chapman Date: Wed, 15 Apr 2009 10:52:00 +1000 Subject: [PATCH] Add and http-delete --- basis/http/client/client.factor | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index f4764ff6f2..d1997c73f9 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -1,6 +1,6 @@ ! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs debugger kernel math math.parser namespaces make +USING: accessors assocs kernel math math.parser namespaces make sequences strings splitting calendar continuations accessors vectors math.order hashtables byte-arrays destructors io io.sockets io.streams.string io.files io.timeouts @@ -128,26 +128,19 @@ SYMBOL: redirects [ do-redirect ] [ nip ] if ] with-variable ; inline recursive -PRIVATE> - : ( url method -- request ) swap >>method swap >url ensure-port >>url ; inline +PRIVATE> + : success? ( code -- ? ) 200 299 between? ; -! ERROR: download-failed response data ; - -! M: download-failed error. -! "HTTP request failed:" print nl -! [ response>> . ] [ data>> . ] bi ; ERROR: download-failed response ; : check-response ( response -- response ) dup code>> success? [ download-failed ] unless ; -! : check-response ( response data -- response data ) - ! over code>> success? [ download-failed ] unless ; : check-response-with-body ( response body -- response body ) [ >>body check-response ] keep ; @@ -166,19 +159,7 @@ ERROR: download-failed response ; http-request ; : with-http-get ( url quot -- response ) - [ ] dip with-http-request check-response ; inline - -! : ( url -- request ) -! "DELETE" ; - -! : http-delete ( url -- response ) -! http-request ; - -! : ( url -- request ) -! "TRACE" >>method ; - -! : http-trace ( url -- response ) -! http-request ; + [ ] dip with-http-request ; inline : download-name ( url -- name ) present file-name "?" split1 drop "/" ?tail drop ; @@ -203,6 +184,12 @@ ERROR: download-failed response ; : http-put ( post-data url -- response data ) http-request ; +: ( url -- request ) + "DELETE" ; + +: http-delete ( url -- response data ) + http-request ; + USING: vocabs vocabs.loader ; "debugger" vocab [ "http.client.debugger" require ] when