libidav/session.c

changeset 788
9b9420041d8e
parent 777
15006651a5d1
child 790
7110b37f2a6b
equal deleted inserted replaced
787:bd96cbb0e205 788:9b9420041d8e
172 172
173 CURLcode dav_session_curl_perform_buf(DavSession *sn, CxBuffer *request, CxBuffer *response, long *status) { 173 CURLcode dav_session_curl_perform_buf(DavSession *sn, CxBuffer *request, CxBuffer *response, long *status) {
174 CURLcode ret = curl_easy_perform(sn->handle); 174 CURLcode ret = curl_easy_perform(sn->handle);
175 long http_status; 175 long http_status;
176 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status); 176 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status);
177 if(ret == CURLE_OK && http_status == 401 && sn->auth_prompt) { 177 if(ret == CURLE_OK) {
178 if(!sn->auth_prompt(sn, sn->authprompt_userdata)) { 178 if(sn->logfunc) {
179 char *log_method;
180 char *log_url;
181 curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_URL, &log_url);
182 curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_METHOD , &log_method);
183 char *log_reqbody = NULL;
184 size_t log_reqbodylen = 0;
185 char *log_rpbody = NULL;
186 size_t log_rpbodylen = 0;
179 if(request) { 187 if(request) {
180 cxBufferSeek(request, 0, SEEK_SET); 188 log_reqbody = request->space;
189 log_reqbodylen = request->size;
181 } 190 }
182 if(response) { 191 if(response) {
183 cxBufferSeek(response, 0, SEEK_SET); 192 log_rpbody = response->space;
184 } 193 log_rpbodylen = response->size;
185 ret = curl_easy_perform(sn->handle); 194 }
186 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status); 195 sn->logfunc(sn, log_method, log_url, log_reqbody, log_reqbodylen, http_status, log_rpbody, log_rpbodylen);
187 } 196 }
188 } 197
198 if(http_status == 401 && sn->auth_prompt) {
199 if(!sn->auth_prompt(sn, sn->authprompt_userdata)) {
200 if(request) {
201 cxBufferSeek(request, 0, SEEK_SET);
202 }
203 if(response) {
204 cxBufferSeek(response, 0, SEEK_SET);
205 }
206 ret = curl_easy_perform(sn->handle);
207 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &http_status);
208 }
209 }
210
211 }
212
189 if(status) { 213 if(status) {
190 *status = http_status; 214 *status = http_status;
191 } 215 }
192 return ret; 216 return ret;
193 } 217 }

mercurial