From 7d48bb3f469ea76596e0516ed2515b2bf1fa8302 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 14 Feb 2013 22:37:03 +0000 Subject: [PATCH] 2013-12-14 14:26 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbtip/httpcli.prg + Added: method :Put( xPostData, cQuery ). This is identical to :Post() but issues PUT verb instead of POST. PUT verb is required for certain RESTful operations. --- harbour/ChangeLog.txt | 8 +++++++- harbour/contrib/hbtip/httpcli.prg | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/harbour/ChangeLog.txt b/harbour/ChangeLog.txt index c9f6c3f0c1..0f8049685d 100644 --- a/harbour/ChangeLog.txt +++ b/harbour/ChangeLog.txt @@ -1,4 +1,4 @@ -/* +/* * $Id$ */ @@ -10,6 +10,12 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-12-14 14:26 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbtip/httpcli.prg + + Added: method :Put( xPostData, cQuery ). + This is identical to :Post() but issues PUT verb instead of POST. + PUT verb is required for certain RESTful operations. + 2013-02-14 23:09 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/xhb/hbxml.c ! several memory leaks fixed in xhb XML support (TXml class) diff --git a/harbour/contrib/hbtip/httpcli.prg b/harbour/contrib/hbtip/httpcli.prg index debb43855f..9c9f1426b9 100644 --- a/harbour/contrib/hbtip/httpcli.prg +++ b/harbour/contrib/hbtip/httpcli.prg @@ -73,6 +73,7 @@ CREATE CLASS TIPClientHTTP FROM TIPClient METHOD New( oUrl, xTrace, oCredentials ) METHOD Get( cQuery ) METHOD Post( xPostData, cQuery ) + METHOD Put( xPostData, cQuery ) METHOD ReadHeaders( lClear ) METHOD Read( nLen ) METHOD UseBasicAuth() INLINE ::cAuthMode := "Basic" @@ -84,10 +85,12 @@ CREATE CLASS TIPClientHTTP FROM TIPClient METHOD PostMultiPart( xPostData, cQuery ) METHOD WriteAll( cFile ) - HIDDEN: - METHOD StandardFields() + PROTECTED: + + METHOD PostByVerb( xPostData, cQuery, cVerb ) + ENDCLASS METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientHTTP @@ -119,8 +122,18 @@ METHOD Get( cQuery ) CLASS TIPClientHTTP METHOD Post( xPostData, cQuery ) CLASS TIPClientHTTP + RETURN ::postByVerb( xPostData, cQuery, "POST" ) + +METHOD Put( xPostData, cQuery ) CLASS TIPClientHTTP + + RETURN ::postByVerb( xPostData, cQuery, "PUT" ) + +METHOD PostByVerb( xPostData, cQuery, cVerb ) CLASS TIPClientHTTP + LOCAL cData, nI, cTmp, y + hb_default( @cVerb, "POST" ) + IF HB_ISHASH( xPostData ) cData := "" y := Len( xPostData ) @@ -155,7 +168,7 @@ METHOD Post( xPostData, cQuery ) CLASS TIPClientHTTP cQuery := ::oUrl:BuildQuery() ENDIF - ::inetSendAll( ::SocketCon, "POST " + cQuery + " HTTP/1.1" + ::cCRLF ) + ::inetSendAll( ::SocketCon, cVerb + " " + cQuery + " HTTP/1.1" + ::cCRLF ) ::StandardFields() IF ! "Content-Type" $ ::hFields