Fossil SCM
Add the --host option to the "fossil test-xfer" command. Improve the help text on that command, too.
Commit
601948b19ba6e44841cb521b435485012bf4d44891d186a3381506a3e906bdf8
Parent
86bba486c5689d3…
1 file changed
+35
-17
+35
-17
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1846,37 +1846,55 @@ | ||
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | /* |
| 1849 | 1849 | ** COMMAND: test-xfer |
| 1850 | 1850 | ** |
| 1851 | -** This command is used for debugging the server. There is a single | |
| 1852 | -** argument which is the uncompressed content of an "xfer" message | |
| 1853 | -** from client to server. This command interprets that message as | |
| 1854 | -** if had been received by the server. | |
| 1855 | -** | |
| 1856 | -** On the client side, run: | |
| 1857 | -** | |
| 1858 | -** fossil push http://bogus/ --httptrace | |
| 1859 | -** | |
| 1860 | -** Or a similar command to provide the output. The content of the | |
| 1861 | -** message will appear on standard output. Capture this message | |
| 1862 | -** into a file named (for example) out.txt. Then run the | |
| 1863 | -** server in gdb: | |
| 1864 | -** | |
| 1865 | -** gdb fossil | |
| 1866 | -** r test-xfer out.txt | |
| 1851 | +** Usage: %fossil test-xfer ?OPTIONS? XFERFILE | |
| 1852 | +** | |
| 1853 | +** Pass the sync-protocol input file XFERFILE into the server-side sync | |
| 1854 | +** protocol handler. Generate a reply on standard output. | |
| 1855 | +** | |
| 1856 | +** This command was original created to help debug the server side of | |
| 1857 | +** sync messages. The XFERFILE is the uncompressed content of an | |
| 1858 | +** "xfer" HTTP request from client to server. This command interprets | |
| 1859 | +** that message and generates the content of an HTTP reply (without any | |
| 1860 | +** encoding and without the HTTP reply headers) and writes that reply | |
| 1861 | +** on standard output. | |
| 1862 | +** | |
| 1863 | +** One possible usages scenario is to capture some XFERFILE examples | |
| 1864 | +** using a command like: | |
| 1865 | +** | |
| 1866 | +** fossil push http://bogus/ --httptrace | |
| 1867 | +** | |
| 1868 | +** The complete HTTP requests are stored in files named "http-request-N.txt". | |
| 1869 | +** Find one of those requests, remove the HTTP header, and make other edits | |
| 1870 | +** as necessary to generate an appropriate XFERFILE test case. Then run: | |
| 1871 | +** | |
| 1872 | +** fossil test-xfer xferfile.txt | |
| 1873 | +** | |
| 1874 | +** Options: | |
| 1875 | +** | |
| 1876 | +** --host HOSTNAME Supply a server hostname used to populate | |
| 1877 | +** g.zBaseURL and similar. | |
| 1867 | 1878 | */ |
| 1868 | 1879 | void cmd_test_xfer(void){ |
| 1880 | + const char *zHost; | |
| 1869 | 1881 | db_find_and_open_repository(0,0); |
| 1882 | + zHost = find_option("host",0,1); | |
| 1883 | + verify_all_options(); | |
| 1870 | 1884 | if( g.argc!=2 && g.argc!=3 ){ |
| 1871 | 1885 | usage("?MESSAGEFILE?"); |
| 1872 | 1886 | } |
| 1887 | + if( zHost==0 ) zHost = "localhost:8080"; | |
| 1888 | + g.zBaseURL = mprintf("http://%s", zHost); | |
| 1889 | + g.zHttpsURL = mprintf("https://%s", zHost); | |
| 1890 | + g.zTop = mprintf(""); | |
| 1873 | 1891 | blob_zero(&g.cgiIn); |
| 1874 | 1892 | blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE); |
| 1875 | 1893 | disableLogin = 1; |
| 1876 | 1894 | page_xfer(); |
| 1877 | - fossil_print("%s\n", cgi_extract_content()); | |
| 1895 | + fossil_print("%s", cgi_extract_content()); | |
| 1878 | 1896 | } |
| 1879 | 1897 | |
| 1880 | 1898 | /* |
| 1881 | 1899 | ** Format strings for progress reporting. |
| 1882 | 1900 | */ |
| 1883 | 1901 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1846,37 +1846,55 @@ | |
| 1846 | } |
| 1847 | |
| 1848 | /* |
| 1849 | ** COMMAND: test-xfer |
| 1850 | ** |
| 1851 | ** This command is used for debugging the server. There is a single |
| 1852 | ** argument which is the uncompressed content of an "xfer" message |
| 1853 | ** from client to server. This command interprets that message as |
| 1854 | ** if had been received by the server. |
| 1855 | ** |
| 1856 | ** On the client side, run: |
| 1857 | ** |
| 1858 | ** fossil push http://bogus/ --httptrace |
| 1859 | ** |
| 1860 | ** Or a similar command to provide the output. The content of the |
| 1861 | ** message will appear on standard output. Capture this message |
| 1862 | ** into a file named (for example) out.txt. Then run the |
| 1863 | ** server in gdb: |
| 1864 | ** |
| 1865 | ** gdb fossil |
| 1866 | ** r test-xfer out.txt |
| 1867 | */ |
| 1868 | void cmd_test_xfer(void){ |
| 1869 | db_find_and_open_repository(0,0); |
| 1870 | if( g.argc!=2 && g.argc!=3 ){ |
| 1871 | usage("?MESSAGEFILE?"); |
| 1872 | } |
| 1873 | blob_zero(&g.cgiIn); |
| 1874 | blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE); |
| 1875 | disableLogin = 1; |
| 1876 | page_xfer(); |
| 1877 | fossil_print("%s\n", cgi_extract_content()); |
| 1878 | } |
| 1879 | |
| 1880 | /* |
| 1881 | ** Format strings for progress reporting. |
| 1882 | */ |
| 1883 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1846,37 +1846,55 @@ | |
| 1846 | } |
| 1847 | |
| 1848 | /* |
| 1849 | ** COMMAND: test-xfer |
| 1850 | ** |
| 1851 | ** Usage: %fossil test-xfer ?OPTIONS? XFERFILE |
| 1852 | ** |
| 1853 | ** Pass the sync-protocol input file XFERFILE into the server-side sync |
| 1854 | ** protocol handler. Generate a reply on standard output. |
| 1855 | ** |
| 1856 | ** This command was original created to help debug the server side of |
| 1857 | ** sync messages. The XFERFILE is the uncompressed content of an |
| 1858 | ** "xfer" HTTP request from client to server. This command interprets |
| 1859 | ** that message and generates the content of an HTTP reply (without any |
| 1860 | ** encoding and without the HTTP reply headers) and writes that reply |
| 1861 | ** on standard output. |
| 1862 | ** |
| 1863 | ** One possible usages scenario is to capture some XFERFILE examples |
| 1864 | ** using a command like: |
| 1865 | ** |
| 1866 | ** fossil push http://bogus/ --httptrace |
| 1867 | ** |
| 1868 | ** The complete HTTP requests are stored in files named "http-request-N.txt". |
| 1869 | ** Find one of those requests, remove the HTTP header, and make other edits |
| 1870 | ** as necessary to generate an appropriate XFERFILE test case. Then run: |
| 1871 | ** |
| 1872 | ** fossil test-xfer xferfile.txt |
| 1873 | ** |
| 1874 | ** Options: |
| 1875 | ** |
| 1876 | ** --host HOSTNAME Supply a server hostname used to populate |
| 1877 | ** g.zBaseURL and similar. |
| 1878 | */ |
| 1879 | void cmd_test_xfer(void){ |
| 1880 | const char *zHost; |
| 1881 | db_find_and_open_repository(0,0); |
| 1882 | zHost = find_option("host",0,1); |
| 1883 | verify_all_options(); |
| 1884 | if( g.argc!=2 && g.argc!=3 ){ |
| 1885 | usage("?MESSAGEFILE?"); |
| 1886 | } |
| 1887 | if( zHost==0 ) zHost = "localhost:8080"; |
| 1888 | g.zBaseURL = mprintf("http://%s", zHost); |
| 1889 | g.zHttpsURL = mprintf("https://%s", zHost); |
| 1890 | g.zTop = mprintf(""); |
| 1891 | blob_zero(&g.cgiIn); |
| 1892 | blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE); |
| 1893 | disableLogin = 1; |
| 1894 | page_xfer(); |
| 1895 | fossil_print("%s", cgi_extract_content()); |
| 1896 | } |
| 1897 | |
| 1898 | /* |
| 1899 | ** Format strings for progress reporting. |
| 1900 | */ |
| 1901 |