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.
This commit is contained in:
Pritpal Bedi
2013-02-14 22:37:03 +00:00
parent 78e179c85c
commit 7d48bb3f46
2 changed files with 23 additions and 4 deletions

View File

@@ -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)

View File

@@ -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