Subject: bug#51875: 28.0.60; HTTP request sent to HTTPS port when using SOCKS proxy

From: [email-masked]
Date: Mon, 15 Nov 2021 20:43:49 +0400

Seems like Emacs is sending HTTP requests to HTTPS ports when a socks
proxy is configured. I tested this several times and got the same result.

Good scenario:
- emacs -Q
- M-x eww RET anything RET
- Result: Shows DDG search results

Bad scenario:
- emacs -Q
- Eval these lines in the scratch buffer or add them to init.el after
replacing the SOCKS5 proxy with your own:
```
(customize-set-variable 'socks-override-functions t)
(customize-set-variable 'socks-noproxy '("127.0.0.1"))
(customize-set-variable 'socks-server '("Default server" "172.16.211.16" 1080 5))
(customize-set-variable 'url-gateway-method 'socks)
(require 'socks)
```
- M-x eww RET something else RET
- Shows:
```
400 Bad Request

The plain HTTP request was sent to HTTPS port 
-------------------------------------------------------
nginx
```

In GNU Emacs 28.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
Windowing system distributor 'System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16/bin/bash
 SHELL=/gnu/store/pwcp239kjf7lnj5i4lkdzcfcxwcfyk72-bash-minimal-5.0.16/bin/bash
 --prefix=/gnu/store/lgxd5ccj88lk5x6kpfwjr4s32lpaky8c-emacs-pgtk-native-comp-28.0.60-213.eb9197b
 --enable-fast-install --with-native-compilation --with-pgtk
 --with-xwidgets --with-modules --with-cairo --disable-build-details'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LIBOTF LIBSELINUX LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM
XWIDGETS GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: /gnu/store/lgxd5ccj88lk5x6kpfwjr4s32lpaky8c-emacs-pgtk-native-comp-28.0.60-213.eb9197b/share/emacs/28.0.60/lisp
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message dired dired-loaddefs rfc822 mml
mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode
mailabbrev gmm-utils mailheader sendmail socks cus-edit pp cus-start
cus-load jka-compr cl-extra help-mode gnutls network-stream url-http
mail-parse rfc2231 url-gw nsm rmc url-cache url-auth format-spec eww xdg
url-queue thingatpt shr kinsoku svg xml dom browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util url-parse url-vars mailcap puny mm-url gnus nnheader gnus-util
rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map rfc2047 rfc2045 ietf-drums
text-property-search time-date subr-x seq byte-opt gv bytecomp
byte-compile cconv mail-utils wid-edit mm-util mail-prsvr cl-loaddefs
cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit pgtk multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 240947 9817)
 (symbols 48 10976 0)
 (strings 32 59931 3030)
 (string-bytes 1 3275385)
 (vectors 16 20000)
 (vector-slots 8 406352 23530)
 (floats 8 66 85)
 (intervals 56 4607 524)
 (buffers 992 13))