Legal/adding notice for libcurl sample (#372)

* Adding libcurl sample usage to Notice
This commit is contained in:
Victor Vazquez 2020-09-04 21:15:35 +00:00 committed by GitHub
parent 40d013b030
commit 68ee875fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 30 deletions

View File

@ -64,6 +64,7 @@ Copyright (c) 2009 Florian Loitsch (http://florian.loitsch.com/)
Copyright (c) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (c) 2008-2009 Bjorn Hoehrmann (http://bjoern.hoehrmann.de/) <bjoern@hoehrmann.de>
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de> sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa
Copyright (c) 1996 - 2020, Daniel Stenberg, <daniel@haxx.se>
MIT License
@ -488,5 +489,27 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1996 - 2020, Daniel Stenberg, <daniel@haxx.se>, and many
contributors, see the THANKS file.
All rights reserved.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright
notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization of the copyright holder.
-------------------------------------------------------------------

View File

@ -10,6 +10,38 @@
using namespace Azure::Core::Http;
// To wait for a socket to be ready to be read/write
// Method From: https://github.com/curl/curl/blob/master/docs/examples/sendrecv.c#L32
// Copyright (c) 1996 - 2020, Daniel Stenberg, <daniel@haxx.se>
static int WaitForSocketReady(curl_socket_t sockfd, int for_recv, long timeout_ms)
{
struct timeval tv;
fd_set infd, outfd, errfd;
int res;
tv.tv_sec = timeout_ms / 1000;
tv.tv_usec = (timeout_ms % 1000) * 1000;
FD_ZERO(&infd);
FD_ZERO(&outfd);
FD_ZERO(&errfd);
FD_SET(sockfd, &errfd); /* always check for error */
if (for_recv)
{
FD_SET(sockfd, &infd);
}
else
{
FD_SET(sockfd, &outfd);
}
/* select() returns the number of signalled sockets or -1 */
res = select((int)sockfd + 1, &infd, &outfd, &errfd, &tv);
return res;
}
std::unique_ptr<RawResponse> CurlTransport::Send(Context const& context, Request& request)
{
// Create CurlSession to perform request
@ -169,36 +201,6 @@ static std::unique_ptr<RawResponse> CreateHTTPResponse(std::string const& header
reinterpret_cast<const uint8_t*>(header.data() + header.size()));
}
// To wait for a socket to be ready to be read/write
static int WaitForSocketReady(curl_socket_t sockfd, int for_recv, long timeout_ms)
{
struct timeval tv;
fd_set infd, outfd, errfd;
int res;
tv.tv_sec = timeout_ms / 1000;
tv.tv_usec = (timeout_ms % 1000) * 1000;
FD_ZERO(&infd);
FD_ZERO(&outfd);
FD_ZERO(&errfd);
FD_SET(sockfd, &errfd); /* always check for error */
if (for_recv)
{
FD_SET(sockfd, &infd);
}
else
{
FD_SET(sockfd, &outfd);
}
/* select() returns the number of signalled sockets or -1 */
res = select((int)sockfd + 1, &infd, &outfd, &errfd, &tv);
return res;
}
bool CurlSession::isUploadRequest()
{
return this->m_request.GetMethod() == HttpMethod::Put