A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
tcp/http/httpsame.c@118:067cb5bce7e3, 2019-01-26 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Jan 26 18:57:27 2019 +0000
- Revision:
- 118:067cb5bce7e3
- Parent:
- 109:bca6ebe63e32
Made http headers (just the if modified since) case insensitive.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 109:bca6ebe63e32 | 1 | #include <stdbool.h> |
andrewboyson | 118:067cb5bce7e3 | 2 | #include <ctype.h> |
andrewboyson | 109:bca6ebe63e32 | 3 | #include "http.h" |
andrewboyson | 109:bca6ebe63e32 | 4 | |
andrewboyson | 109:bca6ebe63e32 | 5 | bool HttpSameStr(const char* pa, const char* pb) |
andrewboyson | 109:bca6ebe63e32 | 6 | { |
andrewboyson | 109:bca6ebe63e32 | 7 | if (!pa || !pb) return false; //Handle NULL references |
andrewboyson | 109:bca6ebe63e32 | 8 | |
andrewboyson | 109:bca6ebe63e32 | 9 | while(true) |
andrewboyson | 109:bca6ebe63e32 | 10 | { |
andrewboyson | 109:bca6ebe63e32 | 11 | if ( *pa != *pb) return false; //If they are not the same return false |
andrewboyson | 109:bca6ebe63e32 | 12 | if (!*pa) return true; //If finished return true; |
andrewboyson | 109:bca6ebe63e32 | 13 | pa++; |
andrewboyson | 109:bca6ebe63e32 | 14 | pb++; |
andrewboyson | 109:bca6ebe63e32 | 15 | } |
andrewboyson | 109:bca6ebe63e32 | 16 | } |
andrewboyson | 118:067cb5bce7e3 | 17 | bool HttpSameStrCaseInsensitive(const char* pa, const char* pb) |
andrewboyson | 118:067cb5bce7e3 | 18 | { |
andrewboyson | 118:067cb5bce7e3 | 19 | if (!pa || !pb) return false; //Handle NULL references |
andrewboyson | 118:067cb5bce7e3 | 20 | |
andrewboyson | 118:067cb5bce7e3 | 21 | while(true) |
andrewboyson | 118:067cb5bce7e3 | 22 | { |
andrewboyson | 118:067cb5bce7e3 | 23 | if ( toupper(*pa) != toupper(*pb)) return false; //If they are not the same return false |
andrewboyson | 118:067cb5bce7e3 | 24 | if (!*pa) return true; //If finished return true; |
andrewboyson | 118:067cb5bce7e3 | 25 | pa++; |
andrewboyson | 118:067cb5bce7e3 | 26 | pb++; |
andrewboyson | 118:067cb5bce7e3 | 27 | } |
andrewboyson | 118:067cb5bce7e3 | 28 | } |
andrewboyson | 109:bca6ebe63e32 | 29 | bool HttpSameDate(const char* date, const char* time, const char* pOtherDate) |
andrewboyson | 109:bca6ebe63e32 | 30 | { |
andrewboyson | 109:bca6ebe63e32 | 31 | if (!pOtherDate) return false; //Not the same if no lastModified |
andrewboyson | 109:bca6ebe63e32 | 32 | |
andrewboyson | 109:bca6ebe63e32 | 33 | char pFileDate[HTTP_DATE_LENGTH]; |
andrewboyson | 109:bca6ebe63e32 | 34 | HttpDateFromDateTime(date, time, pFileDate); |
andrewboyson | 109:bca6ebe63e32 | 35 | |
andrewboyson | 109:bca6ebe63e32 | 36 | return HttpSameStr(pFileDate, pOtherDate); |
andrewboyson | 109:bca6ebe63e32 | 37 | } |