Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add brackets in Host header of http request when relevant #54

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions SOURCES/xapi-23.31.0-fix-ipv6-import.XCP-ng.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Add brackets in `Host` header of http request when relevant.
See: https://github.com/mirage/ocaml-cohttp/issues/997

diff --git i/ocaml/xapi/xapi_vm.ml w/ocaml/xapi/xapi_vm.ml
index 4db86acbd..e310f5549 100644
--- i/ocaml/xapi/xapi_vm.ml
+++ w/ocaml/xapi/xapi_vm.ml
@@ -1518,7 +1518,17 @@ let rec import_inner n ~__context ~url ~sr ~full_restore ~force =
Cohttp.Request.Make (Cohttp_posix_io.Unbuffered_IO) in
let module Response =
Cohttp.Response.Make (Cohttp_posix_io.Unbuffered_IO) in
- let request = Cohttp.Request.make ~meth:`GET uri in
+ let headers = Cohttp.Header.init () in
+ let headers =
+ Cohttp.Header.add_unless_exists headers "host"
+ (match Uri.scheme uri with
+ | Some "httpunix" -> ""
+ | _ -> (
+ (Http.Url.maybe_wrap_IPv6_literal (Uri.host_with_default ~default:"localhost" uri))
+ ^
+ match Uri.port uri with Some p -> ":" ^ string_of_int p | None -> ""))
+ in
+ let request = Cohttp.Request.make ~meth:`GET ?headers:(Some headers) uri in
let ic =
{
Cohttp_posix_io.Unbuffered_IO.header_buffer= None
6 changes: 5 additions & 1 deletion SPECS/xapi.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Summary: xapi - xen toolstack for XCP
Name: xapi
Version: 23.31.0
Release: 1.1%{?xsrel}%{?dist}
Release: 1.3%{?xsrel}%{?dist}
Group: System/Hypervisor
License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception
URL: http://www.xen.org
Expand Down Expand Up @@ -61,6 +61,7 @@ Patch1003: xapi-23.24.0-update-db-tunnel-protocol-from-other_config.XCP-ng.patch
# Needed for IPv6 support. Upstream wants a better fix. Drop when upstream fixed it.
Patch1004: xapi-23.3.0-filter-link-local-address-ipv6.XCP-ng.patch
Patch1005: xapi-23.31.0-extend-uefi-cert-api.patch
Patch1006: xapi-23.31.0-fix-ipv6-import.XCP-ng.patch

%{?_cov_buildrequires}
BuildRequires: ocaml-ocamldoc
Expand Down Expand Up @@ -1340,6 +1341,9 @@ Coverage files from unit tests
%{?_cov_results_package}

%changelog
* Thu Feb 08 2024 Benjamin Reis <[email protected]> - 23.31.0-1.3
- Add xapi-23.31.0-fix-ipv6-import.XCP-ng.patch

* Mon Jan 22 2024 Samuel Verschelde <[email protected]> - 23.31.0-1.1
- Rebase on 23.31.0-1
- Rediff patches (Benjamin Reis)
Expand Down