Check-in [601948b19b]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add the --host option to the "fossil test-xfer" command. Improve the help text on that command, too.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 601948b19ba6e44841cb521b435485012bf4d44891d186a3381506a3e906bdf8
User & Date: drh 2021-12-22 13:45:38.511
Context
2021-12-22
14:03
Enhance the test-httpmsg command with the new --xfer option and with an optional extra argument to specify the output file. check-in: 450cfbbfac user: drh tags: trunk
13:45
Add the --host option to the "fossil test-xfer" command. Improve the help text on that command, too. check-in: 601948b19b user: drh tags: trunk
10:57
Fixed a null-pointer deref in /chat JS in the try-to-resend-message error handler. check-in: 86bba486c5 user: stephan tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/xfer.c.
1844
1845
1846
1847
1848
1849
1850





1851
1852
1853


1854
1855

1856
1857
1858
1859
1860
1861

1862
1863

1864

1865

1866
1867
1868

1869


1870
1871
1872




1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
  db_commit_transaction();
  configure_rebuild();
}

/*
** COMMAND: test-xfer
**





** This command is used for debugging the server.  There is a single
** argument which is the uncompressed content of an "xfer" message
** from client to server.  This command interprets that message as


** if had been received by the server.
**

** On the client side, run:
**
**      fossil push http://bogus/ --httptrace
**
** Or a similar command to provide the output.  The content of the
** message will appear on standard output.  Capture this message

** into a file named (for example) out.txt.  Then run the
** server in gdb:

**

**     gdb fossil

**     r test-xfer out.txt
*/
void cmd_test_xfer(void){

  db_find_and_open_repository(0,0);


  if( g.argc!=2 && g.argc!=3 ){
    usage("?MESSAGEFILE?");
  }




  blob_zero(&g.cgiIn);
  blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE);
  disableLogin = 1;
  page_xfer();
  fossil_print("%s\n", cgi_extract_content());
}

/*
** Format strings for progress reporting.
*/
static const char zLabelFormat[] = "%-10s %10s %10s %10s %10s\n";
static const char zValueFormat[] = "\r%-10s %10d %10d %10d %10d\n";







>
>
>
>
>
|
|
|
>
>
|

>
|

|

|
<
>
|
|
>

>
|
>
|


>

>
>



>
>
>
>




|







1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868

1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
  db_commit_transaction();
  configure_rebuild();
}

/*
** COMMAND: test-xfer
**
** Usage: %fossil test-xfer ?OPTIONS? XFERFILE
**
** Pass the sync-protocol input file XFERFILE into the server-side sync
** protocol handler.  Generate a reply on standard output.
**
** This command was original created to help debug the server side of
** sync messages.  The XFERFILE is the uncompressed content of an 
** "xfer" HTTP request from client to server.  This command interprets
** that message and generates the content of an HTTP reply (without any
** encoding and without the HTTP reply headers) and writes that reply
** on standard output.
**
** One possible usages scenario is to capture some XFERFILE examples
** using a command like:
**
**     fossil push http://bogus/ --httptrace
**
** The complete HTTP requests are stored in files named "http-request-N.txt".

** Find one of those requests, remove the HTTP header, and make other edits
** as necessary to generate an appropriate XFERFILE test case.  Then run:
**
**     fossil test-xfer xferfile.txt
**
** Options:
**
**    --host  HOSTNAME             Supply a server hostname used to populate
**                                 g.zBaseURL and similar.
*/
void cmd_test_xfer(void){
  const char *zHost;
  db_find_and_open_repository(0,0);
  zHost = find_option("host",0,1);
  verify_all_options();
  if( g.argc!=2 && g.argc!=3 ){
    usage("?MESSAGEFILE?");
  }
  if( zHost==0 ) zHost = "localhost:8080";
  g.zBaseURL = mprintf("http://%s", zHost);
  g.zHttpsURL = mprintf("https://%s", zHost);
  g.zTop = mprintf("");
  blob_zero(&g.cgiIn);
  blob_read_from_file(&g.cgiIn, g.argc==2 ? "-" : g.argv[2], ExtFILE);
  disableLogin = 1;
  page_xfer();
  fossil_print("%s", cgi_extract_content());
}

/*
** Format strings for progress reporting.
*/
static const char zLabelFormat[] = "%-10s %10s %10s %10s %10s\n";
static const char zValueFormat[] = "\r%-10s %10d %10d %10d %10d\n";