Skip to content

cURL์€ ๋ฆฌ๋ˆ…์Šค์™€ ๋งฅ ํ„ฐ๋ฏธ๋„์—์„œ HTTP ์š”์ฒญ์„ ์ˆ˜ํ–‰ํ•ด๋ณด๊ธฐ ์œ„ํ•ด์„œ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค. ์œˆ๋„์šฐ์—์„œ๋„ ๋งˆ์ดํฌ๋กœ์†Œํ”„ํŠธ์—์„œ ์ œ๊ณตํ•˜๋Š” ์ปฌ ํ”„๋กœ๊ทธ๋žจ์ด ๋‚ด์žฅ๋˜์–ด์žˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ(cmd)๋กœ curl ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์ •์ƒ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ, ์œˆ๋„์šฐ ํ„ฐ๋ฏธ๋„์—์„œ๋Š” ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ๊ฐ€ ์•„๋‹ˆ๋ผ ํŒŒ์›Œ์‰˜(Powershll)์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ Invoke-WebRequest ์œผ๋กœ ํ˜ธ์ถœ๋˜์–ด ๊ธฐ๋ณธ์ ์œผ๋กœ ์•Œ๋˜ ๋ช…๋ น์–ด๊ฐ€ ์ˆ˜ํ–‰๋˜์ง€ ์•Š๋Š”๋‹ค.

shell
C:\Users\Mambo>curl -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
powershell
PS C:\Users\Mambo> curl

cmdlet Invoke-WebRequest(๋ช…๋ น ํŒŒ์ดํ”„๋ผ์ธ ์œ„์น˜ 1)
๋‹ค์Œ ๋งค๊ฐœ ๋ณ€์ˆ˜์— ๋Œ€ํ•œ ๊ฐ’์„ ์ œ๊ณตํ•˜์‹ญ์‹œ์˜ค. 
Uri: okky.kr

StatusCode        : 200
StatusDescription : OK
Content           : <!DOCTYPE html><html lang="ko" class="js-focus-visible h-full"><head><meta charSet="utf-8"/><title>
                    OKKY - All That Developer</title><meta name="robots" content="index,follow"/><meta name="descriptio
                    n"...
RawContent        : HTTP/1.1 200 OK
                    Transfer-Encoding: chunked
                    Connection: keep-alive
                    Vary: Accept-Encoding
                    Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
                    Content-Type: text/html; charset=utf...
Forms             : {}
Headers           : {[Transfer-Encoding, chunked], [Connection, keep-alive], [Vary, Accept-Encoding], [Cache-Control, p
                    rivate, no-cache, no-store, max-age=0, must-revalidate]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 22832

cURL์˜ curl shipped by Microsoft ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด๋ณด๋ฉด Powershell Alias์— ๋Œ€ํ•œ ๋ฌธ์ œ๋กœ ์ธํ•ด curl.exe ๋กœ ํ”„๋กœ๊ทธ๋žจ์„ ์ง€์ •ํ•˜์—ฌ ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋„๋ก ์•ˆ๋‚ดํ•œ๋‹ค.

shell
PS C:\Users\Mambo> curl.exe -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets

ํŒŒ์›Œ์‰˜ Alias ์ œ๊ฑฐํ•˜๊ธฐ โ€‹

Remove-Item ๋ช…๋ น์–ด๋กœ Alias๋ฅผ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๊ณ ๋‚˜์„œ ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ˜„์žฌ ํ”„๋กœํŒŒ์ผ์„ ๋ฉ”๋ชจ์žฅ์œผ๋กœ ์—ด์–ด curl์— ๋Œ€ํ•œ Alias๋ฅผ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋„๋ก ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์—ฌ ์ €์žฅํ•˜๋„๋ก ํ•˜์ž. ์ด์ œ๋Š” ๊ตณ์ด curl.exe ๋ผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ง€์ •ํ•ด์„œ ํ˜ธ์ถœํ•  ํ•„์š”๊ฐ€ ์—†์–ด์ง„๋‹ค.

powershell
PS C:\Users\Mambo> remove-item alias:\curl
PS C:\Users\Mambo> curl -V
curl 8.0.1 (Windows) libcurl/8.0.1 Schannel WinIDN
Release-Date: 2023-03-20
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets

notepad $profile

# ๋ฉ”๋ชจ์žฅ ์ƒ๋‹จ์— ์ž…๋ ฅ
if (Test-Path -Path alias:curl) { Remove-Item alias:curl }

[ํŒ] ๋ฆฌ๋ˆ…์Šค์—์„œ cURL ๋ช…๋ น์–ด ์ถœ๋ ฅ์ด ๊ฐœํ–‰๋˜์ง€ ์•Š์„ ๊ฒฝ์šฐ โ€‹

๊ฐ„ํ˜น ๋ฆฌ๋ˆ…์Šค์—์„œ cURL ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ฉด ์ถœ๋ ฅ ๊ฒฐ๊ณผ๊ฐ€ ๊ฐœํ–‰๋˜์ง€ ์•Š์•„์„œ ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ๋ถˆํŽธํ•จ์„ ๋А๋‚„ ์ˆ˜ ์žˆ๋‹ค. https://stackoverflow.com/a/14614203์— ๋‚˜์™€์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ์‚ฌ์šฉ์ž ๋””๋ ‰ํ† ๋ฆฌ์— .curlrc ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด์„œ ๊ฐœํ–‰์ด ๋™์ž‘ํ•˜๋„๋ก ์ž‘์„ฑํ•ด๋‘๋ฉด ๋œ๋‹ค.

shell
vi ~/.curlrc
-w "\n"

Released under the MIT License.