Fossil

Check-in [e44932b1]
Login

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

Overview
Comment:Rename the HTTP header variable used by httpCmd back to hdr for consistency with other code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tkt-change-hook
Files: files | file ages | folders
SHA1:e44932b12c8d145dde09a414827fac847a2d3dd6
User & Date: mistachkin 2013-10-14 08:20:58
Context
2013-10-14
08:48
Help text enhancements. check-in: 345cb070 user: mistachkin tags: tkt-change-hook
08:20
Rename the HTTP header variable used by httpCmd back to hdr for consistency with other code. check-in: e44932b1 user: mistachkin tags: tkt-change-hook
08:19
Phase 4, simplify usage of TH1 hooks and make more consistent. Assume that the common transfer TH1 script is idempotent. check-in: 0fe1771a user: mistachkin tags: tkt-change-hook
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/th_main.c.

843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
...
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  const char *zSep, *zType, *zRegexp, *zParams;
  Blob header, payload;
  ReCompiled *pRe = 0;
  UrlData urlData;

  if( argc>1 && fossil_strnicmp(argv[1], "-asynchronous\0", 14) ){
    Th_ErrorMessage(interp,
        "synchronous http requests not yet implemented", 0, 0);
    return TH_ERROR;
................................................................................
    return TH_ERROR;
  }
  re_free(pRe);
  if( transport_open(&urlData) ){
    Th_ErrorMessage(interp, transport_errmsg(&urlData), 0, 0);
    return TH_ERROR;
  }
  blob_zero(&header);
  if( strlen(urlData.path)>0 && zParams!=argv[1] ){
    zSep = "";
  }else{
    zSep = "/";
  }
  blob_appendf(&header, "%s %s%s%s HTTP/1.0\r\n",
               zType, zSep, urlData.path, zParams ? zParams : "");
  if( urlData.proxyAuth ){
    blob_appendf(&header, "Proxy-Authorization: %s\r\n", urlData.proxyAuth);
  }
  if( urlData.passwd && urlData.user && urlData.passwd[0]=='#' ){
    char *zCredentials = mprintf("%s:%s", urlData.user, &urlData.passwd[1]);
    char *zEncoded = encode64(zCredentials, -1);
    blob_appendf(&header, "Authorization: Basic %s\r\n", zEncoded);
    fossil_free(zEncoded);
    fossil_free(zCredentials);
  }
  blob_appendf(&header, "Host: %s\r\n", urlData.hostname);
  blob_appendf(&header, "User-Agent: Fossil/" RELEASE_VERSION
                        " (" MANIFEST_DATE " " MANIFEST_VERSION ")\r\n");
  blob_appendf(&header, "Content-Type: text/plain\r\n");
  blob_appendf(&header, "Content-Length: %d\r\n\r\n", blob_size(&payload));
  transport_send(&urlData, &header);
  transport_send(&urlData, &payload);
  transport_close(&urlData);
  Th_SetResult(interp, 0, 0); /* NOTE: Asynchronous, no results yet. */
  return TH_OK;
}

/*







|







 







|





|


|




|



|
|
|
|
|
|







843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
...
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
  Th_Interp *interp,
  void *p,
  int argc,
  const char **argv,
  int *argl
){
  const char *zSep, *zType, *zRegexp, *zParams;
  Blob hdr, payload;
  ReCompiled *pRe = 0;
  UrlData urlData;

  if( argc>1 && fossil_strnicmp(argv[1], "-asynchronous\0", 14) ){
    Th_ErrorMessage(interp,
        "synchronous http requests not yet implemented", 0, 0);
    return TH_ERROR;
................................................................................
    return TH_ERROR;
  }
  re_free(pRe);
  if( transport_open(&urlData) ){
    Th_ErrorMessage(interp, transport_errmsg(&urlData), 0, 0);
    return TH_ERROR;
  }
  blob_zero(&hdr);
  if( strlen(urlData.path)>0 && zParams!=argv[1] ){
    zSep = "";
  }else{
    zSep = "/";
  }
  blob_appendf(&hdr, "%s %s%s%s HTTP/1.0\r\n",
               zType, zSep, urlData.path, zParams ? zParams : "");
  if( urlData.proxyAuth ){
    blob_appendf(&hdr, "Proxy-Authorization: %s\r\n", urlData.proxyAuth);
  }
  if( urlData.passwd && urlData.user && urlData.passwd[0]=='#' ){
    char *zCredentials = mprintf("%s:%s", urlData.user, &urlData.passwd[1]);
    char *zEncoded = encode64(zCredentials, -1);
    blob_appendf(&hdr, "Authorization: Basic %s\r\n", zEncoded);
    fossil_free(zEncoded);
    fossil_free(zCredentials);
  }
  blob_appendf(&hdr, "Host: %s\r\n", urlData.hostname);
  blob_appendf(&hdr, "User-Agent: Fossil/" RELEASE_VERSION
                     " (" MANIFEST_DATE " " MANIFEST_VERSION ")\r\n");
  blob_appendf(&hdr, "Content-Type: text/plain\r\n");
  blob_appendf(&hdr, "Content-Length: %d\r\n\r\n", blob_size(&payload));
  transport_send(&urlData, &hdr);
  transport_send(&urlData, &payload);
  transport_close(&urlData);
  Th_SetResult(interp, 0, 0); /* NOTE: Asynchronous, no results yet. */
  return TH_OK;
}

/*