📄 util.c
字号:
&spool_reader_baton.spool_file_name, tmpfile_path, "", svn_io_file_del_none, pool); if (err) goto cleanup; spool_reader_baton.pool = pool; spool_reader_baton.error = SVN_NO_ERROR; if (ras->compression) decompress_main = ne_decompress_reader(req, ne_accept_2xx, spool_reader, &spool_reader_baton); else ne_add_response_body_reader(req, ne_accept_2xx, spool_reader, &spool_reader_baton); } else { if (ras->compression) decompress_main = ne_decompress_reader(req, ne_accept_2xx, ne_xml_parse_v, success_parser); else ne_add_response_body_reader(req, ne_accept_2xx, ne_xml_parse_v, success_parser); } /* Register the "error" accepter and body-reader with the request -- the one to use when HTTP status is *not* 2XX */ if (ras->compression) decompress_err = ne_decompress_reader(req, ra_dav_error_accepter, ne_xml_parse_v, error_parser); else ne_add_response_body_reader(req, ra_dav_error_accepter, ne_xml_parse_v, error_parser); /* run the request and get the resulting status code. */ rv = ne_request_dispatch(req); if (spool_response) { /* All done with the temporary file we spooled the response into. */ (void) apr_file_close(spool_reader_baton.spool_file); if (spool_reader_baton.error) { err = svn_error_createf (SVN_ERR_RA_DAV_REQUEST_FAILED, NULL, _("Error spooling the %s request response to disk"), method); goto cleanup; } }#ifdef SVN_NEON_0_25 if (decompress_main) ne_decompress_destroy(decompress_main); if (decompress_err) ne_decompress_destroy(decompress_err);#else /* ! SVN_NEON_0_25 */ if (decompress_main) { decompress_rv = ne_decompress_destroy(decompress_main); if (decompress_rv != 0) { rv = decompress_rv; } } if (decompress_err) { decompress_rv = ne_decompress_destroy(decompress_err); if (decompress_rv != 0) { rv = decompress_rv; } }#endif /* if/else SVN_NEON_0_25 */ code = ne_get_status(req)->code; if (status_code) *status_code = code; if (err) /* If the error parser had a problem */ goto cleanup; /* Set the expected code based on the method. */ expected_code = 200; if (strcmp(method, "PROPFIND") == 0) expected_code = 207; if ((code != expected_code) || (rv != NE_OK)) { if (code == 404) { msg = apr_psprintf(pool, _("'%s' path not found"), url); err = svn_error_create(SVN_ERR_RA_DAV_PATH_NOT_FOUND, NULL, msg); } else { msg = apr_psprintf(pool, _("%s of '%s'"), method, url); err = svn_ra_dav__convert_error(sess, msg, rv, pool); } goto cleanup; } /* If we spooled the response to disk instead of parsing on the fly, we now need to go read that sucker back and parse it. */ if (spool_response) { apr_pool_t *subpool = svn_pool_create(pool); err = parse_spool_file(spool_reader_baton.spool_file_name, success_parser, subpool); svn_pool_destroy(subpool); if (err) { svn_error_compose(err, svn_error_createf (SVN_ERR_RA_DAV_REQUEST_FAILED, NULL, _("Error reading spooled %s request response"), method)); goto cleanup; } } /* was there an XML parse error somewhere? */ msg = ne_xml_get_error(success_parser); if (msg != NULL && *msg != '\0') { err = svn_error_createf(SVN_ERR_RA_DAV_REQUEST_FAILED, NULL, _("The %s request returned invalid XML " "in the response: %s (%s)"), method, msg, url); goto cleanup; } /* ### necessary? be paranoid for now. */ err = SVN_NO_ERROR; cleanup: if (req) ne_request_destroy(req); if (success_parser) ne_xml_destroy(success_parser); if (error_parser) ne_xml_destroy(error_parser); if (spool_response && spool_reader_baton.spool_file_name) (void) apr_file_remove(spool_reader_baton.spool_file_name, pool); if (err) return svn_error_createf(err->apr_err, err, _("%s request failed on '%s'"), method, url ); return SVN_NO_ERROR;}svn_error_t *svn_ra_dav__parsed_request(ne_session *sess, const char *method, const char *url, const char *body, apr_file_t *body_file, void set_parser(ne_xml_parser *parser, void *baton), ne_xml_startelm_cb *startelm_cb, ne_xml_cdata_cb *cdata_cb, ne_xml_endelm_cb *endelm_cb, void *baton, apr_hash_t *extra_headers, int *status_code, svn_boolean_t spool_response, apr_pool_t *pool){ return parsed_request(sess, method, url, body, body_file, set_parser, NULL, FALSE, NULL, NULL, NULL, startelm_cb, cdata_cb, endelm_cb, baton, extra_headers, status_code, spool_response, pool);}svn_error_t *svn_ra_dav__parsed_request_compat(ne_session *sess, const char *method, const char *url, const char *body, apr_file_t *body_file, void set_parser(ne_xml_parser *parser, void *baton), const svn_ra_dav__xml_elm_t *elements, svn_ra_dav__xml_validate_cb validate_cb, svn_ra_dav__xml_startelm_cb startelm_cb, svn_ra_dav__xml_endelm_cb endelm_cb, void *baton, apr_hash_t *extra_headers, int *status_code, svn_boolean_t spool_response, apr_pool_t *pool){ return parsed_request(sess, method, url, body, body_file, set_parser, elements, TRUE, validate_cb, startelm_cb, endelm_cb, NULL, NULL, NULL, baton, extra_headers, status_code, spool_response, pool);}svn_error_t *svn_ra_dav__maybe_store_auth_info(svn_ra_dav__session_t *ras, apr_pool_t *pool){ /* No auth_baton? Never mind. */ if (! ras->callbacks->auth_baton) return SVN_NO_ERROR; /* If we ever got credentials, ask the iter_baton to save them. */ SVN_ERR(svn_auth_save_credentials(ras->auth_iterstate, pool)); return SVN_NO_ERROR;}svn_error_t *svn_ra_dav__maybe_store_auth_info_after_result(svn_error_t *err, svn_ra_dav__session_t *ras, apr_pool_t *pool){ if (! err || (err->apr_err != SVN_ERR_RA_NOT_AUTHORIZED)) { svn_error_t *err2 = svn_ra_dav__maybe_store_auth_info(ras, pool); if (err2 && ! err) return err2; else if (err) { svn_error_clear(err2); return err; } } return err;}voidsvn_ra_dav__add_error_handler(ne_request *request, ne_xml_parser *parser, svn_error_t **err, apr_pool_t *pool){ shim_xml_push_handler(parser, error_elements, validate_error_elements, start_err_element, end_err_element, err, pool); ne_add_response_body_reader(request, ra_dav_error_accepter, ne_xml_parse_v, parser); }svn_error_t *svn_ra_dav__request_dispatch(int *code_p, ne_request *request, ne_session *session, const char *method, const char *url, int okay_1, int okay_2,#ifdef SVN_NEON_0_25 svn_ra_dav__request_interrogator interrogator, void *interrogator_baton,#endif /* SVN_NEON_0_25 */ apr_pool_t *pool){ ne_xml_parser *error_parser; int rv; const ne_status *statstruct; const char *code_desc; int code; const char *msg; svn_error_t *err = SVN_NO_ERROR;#ifdef SVN_NEON_0_25 svn_error_t *err2 = SVN_NO_ERROR;#endif /* SVN_NEON_0_25 */ /* attach a standard <D:error> body parser to the request */ error_parser = ne_xml_create(); shim_xml_push_handler(error_parser, error_elements, validate_error_elements, start_err_element, end_err_element, &err, pool); ne_add_response_body_reader(request, ra_dav_error_accepter, ne_xml_parse_v, error_parser); /* run the request, see what comes back. */ rv = ne_request_dispatch(request); statstruct = ne_get_status(request); code_desc = apr_pstrdup(pool, statstruct->reason_phrase); code = statstruct->code; if (code_p) *code_p = code;#ifdef SVN_NEON_0_25 if (interrogator) err2 = (*interrogator)(request, rv, interrogator_baton);#endif /* SVN_NEON_0_25 */ ne_request_destroy(request); ne_xml_destroy(error_parser);#ifdef SVN_NEON_0_25 /* If the request interrogator returned error, pass that along now. */ if (err2) { svn_error_clear(err); return err2; }#endif /* SVN_NEON_0_25 */ /* If the status code was one of the two that we expected, then go ahead and return now. IGNORE any marshalled error. */ if (rv == NE_OK && (code == okay_1 || code == okay_2)) return SVN_NO_ERROR; /* next, check to see if a <D:error> was discovered */ if (err) return err; /* We either have a neon error, or some other error that we didn't expect. */ msg = apr_psprintf(pool, _("%s of '%s'"), method, url); return svn_ra_dav__convert_error(session, msg, rv, pool);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -