ãReal World HTTPããèªãã§ãã¦ãcurl ã³ãã³ãã§ãããéä¿¡ããéã«ã¨ã©ã¼ã«ãªã£ããã対å¦ãè¨è¼ããã
å®è¡ç°å¢
- OS: Windows 10 Pro
- PowerShell: 7.4.0
- curl: 8.4.0
- VSCode: 1.85.0
対å¦åï¼ã¨ã©ã¼ï¼
å®è¡ã³ãã³ã
curl --http1.0 -H "X-Test: Hello" http://localhost:18888
å®è¡çµæ
Invoke-WebRequest : ãã©ã¡ã¼ã¿ã¼ 'Headers' ããã¤ã³ãã§ãã¾ããã"X-Test: Hello" ã®å¤ã "System.String" åãã "System.Collections.IDictionary" åã«å¤æ ã§ãã¾ããã çºçå ´æ è¡:1 æå:19 + curl --http1.0 -H "X-Test: Hello" http://localhost:18888 + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest]ãParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
対å¦
ã¨ã¤ãªã¢ã¹ã®è¨å®ãåé¤ããã
ããã©ã«ãã®ã¨ã¤ãªã¢ã¹è¨å®
CommandType Name Version Source ----------- ---- ------- ------ Alias curl -> Invoke-WebRequest
ã¨ã¤ãªã¢ã¹åé¤ã³ãã³ã
è¨å®ã®è§£é¤ã¯ããã® PowerShell ã³ã³ã½ã¼ã«ã®ã»ãã·ã§ã³ã§ã®ã¿æå¹ã
del alias:curl
ã¨ã¤ãªã¢ã¹åé¤ã³ãã³ãå®è¡å¾ãã¨ã¤ãªã¢ã¹è¨å®ã¯ä»¥ä¸ã®éã解é¤ããã¦ããç¶æ ã¨ãªãã
PS C:\Users\fossi\01_research\01_programming\go> Get-Alias curl Get-Alias : name 'curl' ãå«ãã¨ã¤ãªã¢ã¹ã¯åå¨ããªãããããã®ã³ãã³ãã¯ä¸è´ããã¨ã¤ãªã¢ã¹ãè¦ã¤ãããã¾ããã çºçå ´æ è¡:1 æå:1 + Get-Alias curl + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (curl:String) [Get-Alias], ItemNotFoundException + FullyQualifiedErrorId : ItemNotFoundException,Microsoft.PowerShell.Commands.GetAliasCommand
対å¦å¾ï¼æ£å¸¸ï¼
å®è¡ã³ãã³ã
curl --http1.0 -H "X-Test: Hello" http://localhost:18888
å®è¡çµæ
curl ã³ãã³ããæ£å¸¸ã«å®è¡ãããæå¾ éãã®çµæãå¾ãããã
GET / HTTP/1.0 Host: localhost:18888 Accept: */* User-Agent: curl/8.4.0 X-Test: Hello
è£è¶³
ä»ã®å¯¾å¦ã¨ãã¦ãã¨ã¤ãªã¢ã¹åé¤ã³ãã³ããå®è¡ãããcurl.exe
ã¨ã¤ãã¦å®è¡ããæ¹æ³ããããããã
curl.exe --http1.0 -H "X-Test: Hello" http://localhost:18888