| 118 | ////////////////////////////////////////////////////////////////////////// |
| 119 | |
| 120 | http_mime::http_mime(const char* boundary, |
| 121 | const char* local_charset /* = "gb2312" */) { |
| 122 | assert(boundary && *boundary); |
| 123 | boundary_ = boundary; |
| 124 | |
| 125 | if (local_charset && *local_charset) { |
| 126 | safe_snprintf(local_charset_, sizeof(local_charset_), |
| 127 | "%s", local_charset); |
| 128 | } else { |
| 129 | local_charset_[0] = 0; |
| 130 | } |
| 131 | |
| 132 | decode_on_ = true; |
| 133 | |
| 134 | save_path_.clear(); |
| 135 | mime_state_ = mime_state_alloc(); |
| 136 | |
| 137 | static const char ctype_pre[] = |
| 138 | "Content-Type: multipart/form-data; boundary="; |
| 139 | |
| 140 | // Ϊ��ʹ���ʼ��� mime ����������Ҫģ���һ��ͷ���ֶ� |
| 141 | mime_state_update(mime_state_, ctype_pre, sizeof(ctype_pre) - 1); |
| 142 | size_t len = strlen(boundary); |
| 143 | mime_state_update(mime_state_, boundary, (int) len); |
| 144 | mime_state_update(mime_state_, "\r\n\r\n", 4); |
| 145 | |
| 146 | // ��Ϊ��ͷ��Ϊ����������ͷ�Ƕ���ӽ�ȥ�ģ����Ի����ʵ�ʵ�ƫ������ |
| 147 | // ͨ�� off_ ������ƫ�������� |
| 148 | off_ = 0 - ((long long) sizeof(ctype_pre) - 1 + (long long) len + 4); |
| 149 | |
| 150 | parsed_ = false; |
| 151 | } |
| 152 | |
| 153 | http_mime::~http_mime() { |
| 154 | if (mime_state_) { |
nothing calls this directly
no test coverage detected