v icon indicating copy to clipboard operation
v copied to clipboard

post requests not work

Open comoum opened this issue 8 months ago • 9 comments

V version: V 0.4.10 b76997a, press to see full `v doctor` output
V full version V 0.4.10 f4b51d0.b76997a
OS windows, Microsoft Windows 10 专业版 19045 64-bit
Processor 16 cpus, 64bit, little endian, AMD Ryzen 7 4700G with Radeon Graphics
Memory 1.35GB/31.36GB
V executable D:\psoft\vlang\v.exe
V last modified time 2025-04-15 09:15:57
V home dir OK, value: D:\psoft\vlang
VMODULES OK, value: D:\psoft\vlang.vmodules
VTMP OK, value: D:\psoft\vlang.vtemp
Current working dir OK, value: D:\space\zig\buy_ticket\vlang
Git version git version 2.35.1.windows.2
V git status weekly.2025.14-49-gb76997a0
.git/config present true
cc version N/A
gcc version gcc (x86_64-win32-seh-rev1, Built by MinGW-Builds project) 13.1.0
clang version clang version 15.0.7
msvc version 用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.29.30158 版
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version ldd (cygwin) 3.3.3

What did you do? ./v -g -o vdbg cmd/v && ./vdbg .\src\main.v && D:\space\zig\buy_ticket\vlang\src\main.exe

module main

// import ilog
// import logic
import net.http

fn main() {
	// ilog.info('hello world')
	// logic.check_login_verify('')!
	http.post('http://www.baidu.com', '')!
}

What did you see?

Error 10057 sending data to server (1)
Error performing handshake
Error 10057 sending data to server (1)
Error performing handshake
Error 10057 sending data to server (1)
Error performing handshake
Error 10057 sending data to server (1)
Error performing handshake
Error 10057 sending data to server (1)
Error performing handshake
V panic: result not set (response does not start with HTTP/, line: ``)
v hash: b76997a
D:/psoft/vlang/.vtemp/main.01JRWBTQGH1273454ESCCM1TM1.tmp.c:9370: at _v_panic: Backtrace
D:/psoft/vlang/.vtemp/main.01JRWBTQGH1273454ESCCM1TM1.tmp.c:9333: by panic_result_not_set
D:/psoft/vlang/.vtemp/main.01JRWBTQGH1273454ESCCM1TM1.tmp.c:19485: by main__main
D:/psoft/vlang/.vtemp/main.01JRWBTQGH1273454ESCCM1TM1.tmp.c:19793: by wmain
005661d0 : by ???
00566333 : by ???
7fff9bf07374 : by ???

What did you expect to see?

post请求访问一个链接时正常响应,就像curl -X POST 'http://www.baidu.com'的结果一样\n\nPost requests to access a link normally respond, just like the result of curl -X POST 'http://www.baidu.com'

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.

comoum avatar Apr 15 '25 09:04 comoum

Connected to Huly®: V_0.6-22608

huly-for-github[bot] avatar Apr 15 '25 09:04 huly-for-github[bot]

This worked for me (linux):

module main

import net.http

fn main() {
	a := http.get('http://www.baidu.com')!
	println('${a.body.len}')
	b := http.post('http://www.baidu.com', '')!
	println('${b.body.len}')
}
$ v run 24226.v
514029
19825
$ v version
V 0.4.10 711470d

Tested in windows and worked too.

jorgeluismireles avatar Apr 15 '25 15:04 jorgeluismireles

It works for me on linux.

This may be more of a networking issue, as in @jemuky internet connection, rather than a problem with V.

JalonSolov avatar Apr 15 '25 16:04 JalonSolov

Does the "v -d use_openssl" work here too? See: https://github.com/vlang/v/issues/23717

BadaBingBee avatar Apr 26 '25 17:04 BadaBingBee

Does the "v -d use_openssl" work here too? See: #23717

it doesn't work too, the error is "builder error: 'openssl/rand.h' not found", i think it use the openssl.exe of git path, its version is "OpenSSL 1.1.1m 14 Dec 2021" then, i install the new version(OpenSSL 3.5.0 8 Apr 2025 (Library: OpenSSL 3.5.0 8 Apr 2025)) openssl, but the openssl.exe of git is still effective, and I can't specify the new one I installed to take effect then, so the post request can't work too

comoum avatar Apr 28 '25 02:04 comoum

which version shows when you run?: openssl --version

Mine is (on linux): OpenSSL 3.2.4 11 Feb 2025 (Library: OpenSSL 3.2.4 11 Feb 2025)

It sounds like "v -d use_openssl" isn't finding your openssl?

Your code works for me with or without the "use_openssl" flag, but I do get the same error on a different endpoint, "V panic: result not set (response does not start with HTTP/, line: ``", and the flag makes it work in that case.

BadaBingBee avatar Apr 28 '25 07:04 BadaBingBee

which version shows when you run?: openssl --version

Mine is (on linux): OpenSSL 3.2.4 11 Feb 2025 (Library: OpenSSL 3.2.4 11 Feb 2025)

It sounds like "v -d use_openssl" isn't finding your openssl?

Your code works for me with or without the "use_openssl" flag, but I do get the same error on a different endpoint, "V panic: result not set (response does not start with HTTP/, line: ``", and the flag makes it work in that case.

you're right, It's a problem with openssl

i entered openssl --version, it shows OpenSSL 1.1.1m 14 Dec 2021, it is the same as the openssl.exe of git path, so I upgraded it to no avail, because git is also what i need

so i can't specify which openssl i need to use

comoum avatar Apr 28 '25 13:04 comoum

From the github repo page for V:

On Windows, OpenSSL is simply hard to get working correctly. The instructions here may (or may not) help.

JalonSolov avatar Apr 28 '25 13:04 JalonSolov

From the github repo page for V:

On Windows, OpenSSL is simply hard to get working correctly. The instructions here may (or may not) help.

this method is invalid.

then I moved the newly installed openssl environment variable to the top of PATH, then the version is correct.

then i compiled this program, and the program can't work. My program name is "test.exe", and I entered "dumpbin /dependents .\test.exe", it shows

Microsoft (R) COFF/PE Dumper Version 14.29.30158.0        
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file .\test.exe

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    msvcrt.dll
    crypt32.dll
    ws2_32.dll
    secur32.dll
    kernel32.dll
    user32.dll
    "libssl-3-x64"
    "libcrypto-3-x64"

  Summary

       3C000 .data
        5000 .pdata
        2000 .rdata
       46000 .stab
       30000 .stabstr
       9D000 .text

then I entered "which user32", it shows "/usr/bin/which: no user32 in (xxxx)"(xxxx is the PATH), the "libssl-3-x64"is the same as this then I entered "which user32.dll", it shows "/c/Windows/system32/user32.dll", "which libssl-3-x64.dll" is "/c/Program Files/OpenSSL-Win64/bin/libssl-3-x64.dll" so, does vlang need to be linked as libssl-3-x64.dll, instead of libssl-3-x64? And I used "dumpbin /dependents" on another cpp program that linked libcurl and saw

File Type: EXECUTABLE IMAGE

  Image has the following dependencies:

    libcurl-x64.dll
    KERNEL32.dll
    MSVCP140D.dll
    MSVCP140D_ATOMIC_WAIT.dll
    VCRUNTIME140D.dll
    VCRUNTIME140_1D.dll
    ucrtbased.dll

  Summary

        1000 .00cfg
        2000 .data
        D000 .pdata
       3C000 .rdata
        1000 .reloc
        1000 .rsrc
       80000 .text
        1000 .tls
        1000 .voltbl

The link of this program is xxx.dll, so I think some versions of Windows may require the ".dll" suffix to link to dynamic libraries.

comoum avatar Apr 29 '25 02:04 comoum