Commit 07b95ea2 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

tests/util: get a private strncasecompare clone

... since the curlx_* code no longer provides one and we don't link
libcurl to these test servers.
parent 95bd2b3e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ noinst_PROGRAMS = getpart resolve rtspd sockfilt sws tftpd fake_ntlm
CURLX_SRCS = \
 ../../lib/mprintf.c \
 ../../lib/nonblock.c \
 ../../lib/strcase.c \
 ../../lib/strtoofft.c \
 ../../lib/timeval.c \
 ../../lib/warnless.c
@@ -11,7 +10,6 @@ CURLX_SRCS = \
CURLX_HDRS = \
 ../../lib/curlx.h \
 ../../lib/nonblock.h \
 ../../lib/strcase.h \
 ../../lib/strtoofft.h \
 ../../lib/timeval.h \
 ../../lib/warnless.h
+3 −3
Original line number Diff line number Diff line
@@ -590,7 +590,7 @@ static int ProcessRequest(struct httprequest *req)
    if(got_exit_signal)
      return 1; /* done */

    if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
    if((req->cl==0) && strncasecompare("Content-Length:", line, 15)) {
      /* If we don't ignore content-length, we read it and we read the whole
         request including the body before we return. If we've been told to
         ignore the content-length, we will return as soon as all headers
@@ -616,7 +616,7 @@ static int ProcessRequest(struct httprequest *req)
        logmsg("... but will abort after %zu bytes", req->cl);
      break;
    }
    else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
    else if(strncasecompare("Transfer-Encoding: chunked", line,
                            strlen("Transfer-Encoding: chunked"))) {
      /* chunked data coming in */
      chunked = TRUE;
+3 −3
Original line number Diff line number Diff line
@@ -697,7 +697,7 @@ static int ProcessRequest(struct httprequest *req)
    if(got_exit_signal)
      return 1; /* done */

    if((req->cl==0) && curlx_strncasecompare("Content-Length:", line, 15)) {
    if((req->cl==0) && strncasecompare("Content-Length:", line, 15)) {
      /* If we don't ignore content-length, we read it and we read the whole
         request including the body before we return. If we've been told to
         ignore the content-length, we will return as soon as all headers
@@ -723,7 +723,7 @@ static int ProcessRequest(struct httprequest *req)
        logmsg("... but will abort after %zu bytes", req->cl);
      break;
    }
    else if(curlx_strncasecompare("Transfer-Encoding: chunked", line,
    else if(strncasecompare("Transfer-Encoding: chunked", line,
                            strlen("Transfer-Encoding: chunked"))) {
      /* chunked data coming in */
      chunked = TRUE;
+84 −0
Original line number Diff line number Diff line
@@ -305,3 +305,87 @@ void clear_advisor_read_lock(const char *filename)
    logmsg("Error removing lock file %s error: %d %s",
           filename, error, strerror(error));
}


/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because
   its behavior is altered by the current locale. */
static char raw_toupper(char in)
{
#if !defined(CURL_DOES_CONVERSIONS)
  if(in >= 'a' && in <= 'z')
    return (char)('A' + in - 'a');
#else
  switch (in) {
  case 'a':
    return 'A';
  case 'b':
    return 'B';
  case 'c':
    return 'C';
  case 'd':
    return 'D';
  case 'e':
    return 'E';
  case 'f':
    return 'F';
  case 'g':
    return 'G';
  case 'h':
    return 'H';
  case 'i':
    return 'I';
  case 'j':
    return 'J';
  case 'k':
    return 'K';
  case 'l':
    return 'L';
  case 'm':
    return 'M';
  case 'n':
    return 'N';
  case 'o':
    return 'O';
  case 'p':
    return 'P';
  case 'q':
    return 'Q';
  case 'r':
    return 'R';
  case 's':
    return 'S';
  case 't':
    return 'T';
  case 'u':
    return 'U';
  case 'v':
    return 'V';
  case 'w':
    return 'W';
  case 'x':
    return 'X';
  case 'y':
    return 'Y';
  case 'z':
    return 'Z';
  }
#endif

  return in;
}

int strncasecompare(const char *first, const char *second, size_t max)
{
  while(*first && *second && max) {
    if(raw_toupper(*first) != raw_toupper(*second)) {
      break;
    }
    max--;
    first++;
    second++;
  }
  if(0 == max)
    return 1; /* they are equal this far */

  return raw_toupper(*first) == raw_toupper(*second);
}
+3 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -63,4 +63,6 @@ void set_advisor_read_lock(const char *filename);

void clear_advisor_read_lock(const char *filename);

int strncasecompare(const char *first, const char *second, size_t max);

#endif  /* HEADER_CURL_SERVER_UTIL_H */