aboutsummaryrefslogtreecommitdiff
path: root/tests/http-client.scm
blob: 649fa1bfacb90bf3be1ad1120b784b816f9939a4 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-http-client)
  #:use-module (guix http-client)
  #:use-module (guix tests http)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-64)
  #:use-module (rnrs bytevectors)
  #:use-module (rnrs io ports)
  #:use-module (web response)
  #:use-module (web uri))

(test-begin "http-client")

(test-equal "http-fetch, one request, binary"
  (string->utf8 "Hello, world.")
  (with-http-server `((200 "Hello, world."))
    (let* ((port (http-fetch (%local-url)))
           (bv   (get-bytevector-all port)))
      (close-port port)
      bv)))

(test-equal "http-fetch, one request, text"
  "Hello, world."
  (with-http-server `((200 "Hello, world."))
    (let* ((port (http-fetch (%local-url) #:text? #t))
           (data (get-string-all port)))
      (close-port port)
      data)))

(test-equal "http-fetch, redirect"
  "Hello, world."
  (with-http-server `((,(build-response
                         #:code 301
                         #:headers
                         `((location
                            . ,(string->uri-reference "/elsewhere")))
                         #:reason-phrase "Moved")
                       "Redirect!")
                      (200 "Hello, world."))
    (let* ((port (http-fetch (%local-url)))
           (data (get-string-all port)))
      (close-port port)
      data)))

(test-equal "http-fetch, error"
  404
  (with-http-server `((404 "Ne trovita."))
    (guard (c ((http-get-error? c) (http-get-error-code c)))
      (http-fetch (%local-url))
      #f)))

(test-equal "http-fetch, redirect + error"
  403
  (with-http-server `((,(build-response
                         #:code 302
                         #:headers
                         `((location
                            . ,(string->uri-reference "/elsewhere")))
                         #:reason-phrase "Moved")
                       "Redirect!")
                      (403 "Verboten."))
    (guard (c ((http-get-error? c) (http-get-error-code c)))
      (http-fetch (%local-url))
      #f)))

(test-end "http-client")
]: Add gobject-introspection, vala. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Vinicius Monego 2021-10-10gnu: babl: Update to 0.1.88....* gnu/packages/gimp.scm (babl): Update to 0.1.88. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Vinicius Monego 2021-10-02gnu: gegl: Add libraw support....* gnu/packages/gimp.scm (gegl)[inputs]: Add libraw. Mathieu Othacehe 2021-09-10gnu: babl: Don't build documentation....It would require `scp` from openssh and it was not built before. * gnu/packages/gimp.scm (babl)[arguments]: Add `-Dwith-docs=false` to the configure flags. Jonathan Brielmaier 2021-07-24gnu: Use 'search-input-directory' and 'search-input-file' where appropriate....This changes some of the remaining uses of this idiom: (string-append (assoc-ref inputs "LABEL") "FILE") to one of: (search-input-file inputs "FILE") (search-input-directory inputs "FILE") * gnu/packages/axoloti.scm (axoloti-patcher): Use 'search-input-directory'. (axoloti-patcher-next): Likewise. * gnu/packages/bioinformatics.scm (java-picard): Likewise. * gnu/packages/bootloaders.scm (grub-hybrid): Likewise. (u-boot-puma-rk3399): Likewise. (u-boot-rock64-rk3328): Likewise. (u-boot-firefly-rk3399): Likewise. (u-boot-rockpro64-rk3399): Likewise. (u-boot-pinebook-pro-rk3399): Likewise. * gnu/packages/cran.scm (r-shiny): Likewise. (r-shinytree): Likewise. * gnu/packages/education.scm (anki): Likewise. * gnu/packages/emacs-xyz.scm (emacs-flycheck-grammalecte): Likewise. (emacs-rime): Likewise. * gnu/packages/emulators.scm (dolphin-emu): Likewise. * gnu/packages/games.scm (bsd-games): Likewise. (seahorse-adventures): Likewise. (einstein): Likewise. * gnu/packages/gimp.scm (gimp-fourier): Likewise. * gnu/packages/gnome.scm (gspell): Likewise. * gnu/packages/guile-xyz.scm (guile-libyaml): Likewise. * gnu/packages/java.scm (icedtea-7): Likewise. * gnu/packages/language.scm (nimf): Likewise. * gnu/packages/lxde.scm (spacefm): Likewise. * gnu/packages/mail.scm (claws-mail): Likewise. * gnu/packages/netpbm.scm (netpbm): Likewise. * gnu/packages/networking.scm (blueman): Likewise. * gnu/packages/scheme.scm (scm): Likewise. * gnu/packages/security-token.scm (python-fido2): Likewise. * gnu/packages/syndication.scm (rtv): Likewise. * gnu/packages/tls.scm (acme-client): Likewise. * gnu/packages/web.scm (netsurf): Likewise. * gnu/packages/wine.scm (wine-staging): Likewise. * gnu/packages/wxwidgets.scm (wxwidgets): Likewise. Ludovic Courtès 2021-05-22gnu: Meson: Remove special versions....* gnu/packages/audio.scm (lv2-speech-denoiser, libaudec)[arguments]: Remove #:meson. * gnu/packages/build-tools.scm (meson): Update to 0.57.2. (meson-0.55, meson-next): Remove variables. * gnu/packages/datastructures.scm (tllist)[arguments]: Remove. * gnu/packages/fontutils.scm (fcft)[arguments]: Likewise. * gnu/packages/gimp.scm (babl, gegl)[arguments]: Remove #:meson. * gnu/packages/gtk.scm (gdk-pixbuf)[arguments]: Likewise. * gnu/packages/lua.scm (emilua)[arguments]: Likewise. * gnu/packages/music.scm (zrythm)[arguments]: Likewise. * gnu/packages/terminals.scm (foot)[arguments]: Likewise. * gnu/packages/virtualization.scm (qemu)[native-inputs]: Change from MESON-NEXT to MESON. (libvirt)[arguments]: Remove #:meson. * gnu/packages/wm.scm (wlroots, sway)[arguments]: Likewise. Marius Bakke 2021-05-09Merge branch 'master' into core-updates... Conflicts: gnu/local.mk gnu/packages/bioinformatics.scm gnu/packages/django.scm gnu/packages/gtk.scm gnu/packages/llvm.scm gnu/packages/python-web.scm gnu/packages/python.scm gnu/packages/tex.scm guix/build-system/asdf.scm guix/build/emacs-build-system.scm guix/profiles.scm Marius Bakke 2021-04-27gnu: GIMP: Update to 2.10.24....* gnu/packages/gimp.scm (gimp): Update to 2.10.24. [source]: Remove obsolete patch 'gimp-make-gegl-introspect-optional.patch'. * gnu/packages/patches/gimp-make-gegl-introspect-optional.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. Leo Famulari 2021-04-27gnu: gegl: Update to 0.4.30....* gnu/packages/gimp.scm (gegl): Update to 0.4.30. Leo Famulari 2021-04-16Merge remote-tracking branch 'origin/master' into core-updates... Conflicts: gnu/local.mk gnu/packages/boost.scm gnu/packages/chez.scm gnu/packages/compression.scm gnu/packages/crates-io.scm gnu/packages/docbook.scm gnu/packages/engineering.scm gnu/packages/gcc.scm gnu/packages/gl.scm gnu/packages/gtk.scm gnu/packages/nettle.scm gnu/packages/python-check.scm gnu/packages/python-xyz.scm gnu/packages/radio.scm gnu/packages/rust.scm gnu/packages/sqlite.scm guix/build-system/node.scm Efraim Flashner 2021-04-01gnu: gimp: Ship a copy of the gegl patch....As Ludo' rightly points out, GitHub's patches are probably as stable as their tarballs. * gnu/packages/gimp.scm (gimp)[source]: Use SEARCH-PATCHES instead of an origin. * gnu/packages/patches/gimp-make-gegl-introspect-optional.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Tobias Geerinckx-Rice 2021-03-30gnu: gimp: Properly handle missing optional ‘dot’....* gnu/packages/gimp.scm (gimp)[source]: Add a patch to fix a fatal error when ‘dot’ is not in $PATH. (gegl)[arguments]: Move the 'refer-to-dot phase... [inputs]: ...and graphviz... (gegl-for-glimpse)[arguments]: ...here, and... [inputs]: ...here, respectively. (glimpse)[inputs]: Use gegl-for-glimpse gegl variant. Tobias Geerinckx-Rice 2021-03-29gnu: gegl: Refer to dot....* gnu/packages/gimp.scm (gegl)[arguments]: Add a new 'refer-to-dot phase. Tobias Geerinckx-Rice 2021-03-28gnu: gegl: Update to 0.4.28....* gnu/packages/gimp.scm (gegl): Update to 0.4.28. [arguments]: Build with meson@0.55. Tobias Geerinckx-Rice 2021-03-28gnu: babl: Update to 0.1.86....* gnu/packages/gimp.scm (babl): Update to 0.1.86. [arguments]: Build with meson@0.55. Tobias Geerinckx-Rice 2021-03-24Merge remote-tracking branch 'origin/master' into core-updatesEfraim Flashner