LoginSignup
12
19

More than 5 years have passed since last update.

curlを便利に使う為の.curlrcの雛型

Last updated at Posted at 2017-04-06

curlを使う際に毎回同じ設定があったり、curlをベースにしたスクリプトの設定をしたりするのに使う、.curlrcですが、なかなか使える解説が無かったので、自分用に覚え書き

よく買う設定だけ入れているので、全部の項目があるわけではありません。他にも設定をする項目はあります。
多くのLinux/unixだと~/.curlrcか/etc/curlrcに書いて使えばいいかと思います。
また、Windows環境では.curlrcではなく_curlrcを使います。
探索場所は、環境変数CURL_HOME→HOME、なければcurl.exeがあるパスの順にコマンドラインで curl -K curlrc.txt のように明示的に指定するのも手です(2019/01/15 追記)

~/.curlrc
# HTTP-Version

http1.0
#http1.1
#http2

# IPv4/IPv6のどちらを逆引きに使うか

ipv4
#ipv6

# User-Agentの設定

##MS-Edge
#user-agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
##Chrome
#user-agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36"
#IE11
#user-agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
#Firefox
user-agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0"

# Referer (リファラ)の設定

referer = ";auto"

# .netrc を読み込むかどうか

#netrc
#netrc-optional


# サーバーの認証をどうするか

#anyauth

# !!! remote-time dosn't work with ftp upload from stdin !!! : use -R switch for downloading

#remote-time
remote-name-all
create-dirs

# Don't show/download error document - only error code

#fail

# Append to target file when uploading (F/SFTP)

#append

# Use HTTP Basic Authentication

#basic

# Maximum time allowed for connection (seconds)

connect-timeout = 300
speed-time      = 120
speed-limit     = 9000000

# Retry only within this period

retry           = 4
retry-delay     = 5
retry-max-time  = 10

# Convert LF to CRLF in upload

#crlf

# Make the operation more talkative

#verbose
#silent
#show-error

# FTP setup

ftp-create-dirs
ftp-ssl
ftp-pasv
ftp-method = nocwd

# Proxy

#proxy-user = "(ユーザ名):(パスワード)"
#proxy = "http://proxy.xxx.co.jp:(ポート)"

# SSL 証明書

# 古かったりするとError (35)の原因になる
# curl http://curl.haxx.se/ca/cacert.pem -o /usr/ssl/certs/ca-bundle.crt
# で最新にしておくと吉
cacert = /usr/ssl/certs/ca-bundle.crt
capath = /usr/ssl/certs/

# SSLの操作を無視する場合
#insecure
tlsv1
#tlsv1.0
#tlsv1.1
#tlsv1.2
#sslv2
#sslv3

# SSL ciphers to use

#ciphers = PFE

## cookie
cookie-jar = /tmp/.curl_cookies
cookie = /tmp/.curl_cookies

コメントインしたり、コメントアウトしたりして使ってやってください。

12
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
19