本文介绍了如何做SVN http请求签入/提交在HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题

我想使用一个网站做一个签入和签出我的SVN服务器上。我已经得到了全部的寄托到这种地步,我可以做使用jQuery检出。我剩下的问题是合并过程的处理。在MERGE SVN内发射分块响应。但我的主机只是报告错误的请求。Wireshark的告知,传输编码分块微米。但我不能将其设置为分块。如果我设置的contentType为分块体的分块而不是transfere编码。和jquery.ajax()无法提供的东西作为传输编码。试图把它变成了头没有工作,以及...它甚至没有表现出这个头

i want to use a website to do a checkin and checkout on my svn server.i already got everthing to the point where i can do a checkout using jQuery.my remaining problem is with the handling of the MERGE process.within the MERGE svn transmits a chunked response.but my console just reports Bad Request.wireshark told m that the Transfer-Encoding is chunked.but i couldn't set it to chunked. if i set the contentType to chunked the body is chunked not the transfere-encoding.and jquery.ajax() doesn't provide something as Transfer-Encoding.trying to put it into the headers didn't work as well...it didn't even show this header

我签code:

    $.ajax({
        type: "OPTIONS",
        url: baseURL,
        contentType: "text/xml",
        data: '<?xml version="1.0" encoding="utf-8" ?><D:options xmlns:D="DAV:"><D:activity-collection-set></D:activity-collection-set></D:options>',
        success: function(data1, status, jqxhr){
            $.ajax({
                type: "POST",
                url: baseURL + "/!svn/me",
                contentType: "application/vnd.svn-skel",
                data: "(create-txn-with-props (svn:txn-user-agent 40 SVN/1.8.9(i686-pc-linux-gnu) serf/1.3.4 svn:log function svn:txn-client-compat-version 5 1.8.9))",
                success: function(data2, status, jqxhr){
                    rev = jqxhr.getResponseHeader('SVN-Txn-Name');
                    newdata = new XMLSerializer().serializeToString(xmlString["context"]);
                    hashResult = calcMD5(newdata);
                    $.ajax({
                        type: "PUT",
                        url: baseURL + "/!svn/txr/" + rev + file + ".xml",
                        headers: {"X-SVN-Version-Name": latestRev, "X-SVN-Base-Fulltext-MD5":hashBase, "X-SVN-Result-Fulltext-MD5": hashResult},
                        contentType: "text/xml",
                        data: newdata,
                        success: function(data3, status, jqxhr){
                            chunked1 = '<?xml version="1.0" encoding="utf-8"?><D:merge xmlns:D="DAV:"><D:source><D:href>/svn/check/!svn/txn/' + rev + '</D:href></D:source><D:no-auto-merge></D:no-auto-merge><D:no-checkout></D:no-checkout><D:prop><D:checked-in></D:checked-in><D:version-name></D:version-name><D:resourcetype></D:resourcetype><D:creationdate></D:creationdate><D:creator-displayname>';
                            chunked2 = '</D:creator-displayname></D:prop></D:merge>';
                            length1 = chunked1.length;
                            length2 = chunked2.length;
                            $.ajax({
                                type: "MERGE",
                                url: baseURL,
                                headers: {"X-SVN-Options": "release-locks"},
                                contentType: "text/xml",
                                data: length1 + chunked1 + length2 + chunked2,
                                success: function(data4, status, jqxhr){
                                    alert('file submitted');
                                },
                                error: function(jqXHR, textStatus, errorThrown) {
                                    alert(textStatus + ' at MERGE \n' + textStatus);
                                }
                            });
                        },
                        error: function(jqXHR, textStatus, errorThrown) {
                            alert(textStatus + ' at PUT\n' + textStatus);
                            $.ajax({
                                type: "DELETE",
                                url: baseURL + "/!svn/txn/" + rev,
                                success: function(data3, status, jqxhr){
                                    alert('file deleted');
                                }
                            });
                        }
                    });
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(textStatus + ' at POST\n' + textStatus);
                }
            });
        },
        error: function(jqXHR, textStatus, errorThrown) {
            alert(textStatus + ' at OPTIONS\n' + textStatus);
        }
    });

编辑:纠正了我的code一些错误从PUT合并改变了problemfocus,因为我发现这个问题问题是,我内的X-SVN-版本名称发送的不只是数字,但数字,因此错误的文件是出于日期

corrected some mistakes in my codechanged the problemfocus from PUT to MERGE, because i found the problemthe problem was that i transmitted within the "X-SVN-Version-Name" not just the number but 'number', therefore the error "File is out of Date"

推荐答案

设置的contentType:为text / xml数据:chunked1 + chunked2

不是一切工作正常和svn接受的文件

than everything works fine and svn accepts the file

这篇关于如何做SVN http请求签入/提交在HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 17:47