def get_content_type(mimetype, ๋ฌธ์ ์งํฉ):
"""mimetype์ ๋ํ charset๊ณผ ํจ๊ป ์ ์ฒด ์ฝํ
์ธ ์ ํ ๋ฌธ์์ด์ ๋ฐํํฉ๋๋ค.
mimetype์ด ํ
์คํธ๋ฅผ ๋ํ๋ด๋ ๊ฒฝ์ฐ charset์ charset์ผ๋ก ์ถ๊ฐ๋ฉ๋๋ค.
๋งค๊ฐ๋ณ์, ๊ทธ๋ ์ง ์์ผ๋ฉด mimetype์ด ๋ณ๊ฒฝ๋์ง ์๊ณ ๋ฐํ๋ฉ๋๋ค.
:param mimetype: ์ฝํ
์ธ ์ ํ์ผ๋ก ์ฌ์ฉํ mimetype.
:param charset: ํ
์คํธ mimetype์ธ ๊ฒฝ์ฐ ์ถ๊ฐํ charset์
๋๋ค.
:return: ์ฝํ
์ธ ์ ํ์
๋๋ค.
""
mimetype.startswith('text/') ๋๋ \
mimetype == '์์ฉ ํ๋ก๊ทธ๋จ/xml' ๋๋ \
(mimetype.startswith('application/') ๋ฐ
mimetype.endswith('+xml')):
๋ง์ ์ ํ += '; charset=' + charset
MIME ์ ํ ๋ฐํ
๋๋ ์ด๊ฒ์ ๋ง์ง๊ธฐ ์์ํ๊ณ ์ธ์ฝ๋ฉ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
"mimetype == 'application/json'"์ ํ๋จํ์ง ์๋ ์ด์ ๋ ๋ฌด์์
๋๊น?
JSON์ ํญ์ UTF-8์ ๋๋ค.
@caiz ๋ ๋ค๋ฅธ ํ ๋ก ์ด ์์ต๋๋ค: https://github.com/request/request/issues/383 , JSON charset์ ๋ํ ์์ธํ ๋ด์ฉ: http://tools.ietf.org/html/rfc4627#section -3
๋์์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
JSON์ ํญ์ UTF-8์ ๋๋ค.