From owner-svn-src-all@freebsd.org Sun Sep 8 20:41:01 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B86E7E12C1; Sun, 8 Sep 2019 20:41:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46RNVP49b1z44Xb; Sun, 8 Sep 2019 20:41:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7267A296E; Sun, 8 Sep 2019 20:41:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x88Kf1iJ035298; Sun, 8 Sep 2019 20:41:01 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x88Kf0Vs035295; Sun, 8 Sep 2019 20:41:00 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201909082041.x88Kf0Vs035295@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sun, 8 Sep 2019 20:41:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352042 - stable/12/lib/libfetch X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/lib/libfetch X-SVN-Commit-Revision: 352042 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Sep 2019 20:41:01 -0000 Author: markj Date: Sun Sep 8 20:41:00 2019 New Revision: 352042 URL: https://svnweb.freebsd.org/changeset/base/352042 Log: MFC r351573: Document fetchReqHTTP(). Modified: stable/12/lib/libfetch/Makefile stable/12/lib/libfetch/fetch.3 stable/12/lib/libfetch/http.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libfetch/Makefile ============================================================================== --- stable/12/lib/libfetch/Makefile Sun Sep 8 20:39:55 2019 (r352041) +++ stable/12/lib/libfetch/Makefile Sun Sep 8 20:41:00 2019 (r352042) @@ -68,6 +68,7 @@ MLINKS+= fetch.3 fetchPutFTP.3 MLINKS+= fetch.3 fetchPutFile.3 MLINKS+= fetch.3 fetchPutHTTP.3 MLINKS+= fetch.3 fetchPutURL.3 +MLINKS+= fetch.3 fetchReqHTTP.3 MLINKS+= fetch.3 fetchStat.3 MLINKS+= fetch.3 fetchStatFTP.3 MLINKS+= fetch.3 fetchStatFile.3 Modified: stable/12/lib/libfetch/fetch.3 ============================================================================== --- stable/12/lib/libfetch/fetch.3 Sun Sep 8 20:39:55 2019 (r352041) +++ stable/12/lib/libfetch/fetch.3 Sun Sep 8 20:41:00 2019 (r352042) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 18, 2016 +.Dd August 28, 2019 .Dt FETCH 3 .Os .Sh NAME @@ -53,6 +53,7 @@ .Nm fetchPutHTTP , .Nm fetchStatHTTP , .Nm fetchListHTTP , +.Nm fetchReqHTTP , .Nm fetchXGetFTP , .Nm fetchGetFTP , .Nm fetchPutFTP , @@ -112,6 +113,8 @@ .Ft struct url_ent * .Fn fetchListHTTP "struct url *u" "const char *flags" .Ft FILE * +.Fn fetchReqHTTP "struct url *u" "const char *method" "const char *flags" "const char *content_type" "const char *body" +.Ft FILE * .Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "const char *flags" .Ft FILE * .Fn fetchGetFTP "struct url *u" "const char *flags" @@ -355,9 +358,10 @@ and password "anonymous@". .Sh HTTP SCHEME The .Fn fetchXGetHTTP , -.Fn fetchGetHTTP -and +.Fn fetchGetHTTP , .Fn fetchPutHTTP +and +.Fn fetchReqHTTP functions implement the HTTP/1.1 protocol. With a little luck, there is even a chance that they comply with RFC2616 and RFC2617. @@ -386,6 +390,18 @@ will send a conditional .Li If-Modified-Since HTTP header to only fetch the content if it is newer than .Va ims_time . +.Pp +The function +.Fn fetchReqHTTP +can be used to make requests with an arbitrary HTTP verb, +including POST, DELETE, CONNECT, OPTIONS, TRACE or PATCH. +This can be done by setting the argument +.Fa method +to the intended verb, such as +.Ql POST , +and +.Fa body +to the content. .Pp Since there seems to be no good way of implementing the HTTP PUT method in a manner consistent with the rest of the Modified: stable/12/lib/libfetch/http.c ============================================================================== --- stable/12/lib/libfetch/http.c Sun Sep 8 20:39:55 2019 (r352041) +++ stable/12/lib/libfetch/http.c Sun Sep 8 20:41:00 2019 (r352042) @@ -2093,6 +2093,9 @@ fetchListHTTP(struct url *url __unused, const char *fl return (NULL); } +/* + * Arbitrary HTTP verb and content requests + */ FILE * fetchReqHTTP(struct url *URL, const char *method, const char *flags, const char *content_type, const char *body)