Changeset 33890 in project


Ignore:
Timestamp:
03/19/17 14:13:09 (8 months ago)
Author:
sjamaan
Message:

http-client: Add early detection of invalid URI argument

As pointed out by Lemonman, the error you got was quite unclear.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/http-client/trunk/http-client.scm

    r33748 r33890  
    22;;; Convenient HTTP client library
    33;;;
    4 ;; Copyright (c) 2008-2016, Peter Bex
     4;; Copyright (c) 2008-2017, Peter Bex
    55;; Parts copyright (c) 2000-2004, Felix L. Winkelmann
    66;; All rights reserved.
     
    773773(define (call-with-input-request* uri-or-request writer reader)
    774774  (let* ((type #f)
    775          (uri (cond ((uri? uri-or-request) uri-or-request)
     775         (uri (cond ((uri-reference? uri-or-request) uri-or-request)
    776776                    ((string? uri-or-request) (uri-reference uri-or-request))
    777                     (else (request-uri uri-or-request))))
     777                    ((request? uri-or-request) (request-uri uri-or-request))
     778                    (else #f)))
     779         (_ (unless (uri? uri)
     780              (http-client-error
     781               'call-with-input-request
     782               (if (uri-reference? uri)
     783                   "Bad argument: URI must be a proper URI, not a relative reference (protocol and host must be set)"
     784                   "The first argument must be either an uri-common object, an intarweb request object, or an URI string")
     785               (list uri-or-request writer reader)
     786               'bad-uri 'uri uri-or-request)))
    778787         (req (if (request? uri-or-request)
    779788                  uri-or-request
Note: See TracChangeset for help on using the changeset viewer.