| 38 | /************************************************************************/ |
| 39 | |
| 40 | static std::string HTTPFetchContentDispositionFilename(char **papszHeaders) |
| 41 | { |
| 42 | char **papszIter = papszHeaders; |
| 43 | while (papszIter && *papszIter) |
| 44 | { |
| 45 | /* For multipart, we have in raw format, but without end-of-line |
| 46 | * characters */ |
| 47 | if (STARTS_WITH(*papszIter, |
| 48 | "Content-Disposition: attachment; filename=")) |
| 49 | { |
| 50 | return SanitizeDispositionFilename(*papszIter + 42); |
| 51 | } |
| 52 | /* For single part, the headers are in KEY=VAL format, but with e-o-l |
| 53 | * ... */ |
| 54 | else if (STARTS_WITH(*papszIter, |
| 55 | "Content-Disposition=attachment; filename=")) |
| 56 | { |
| 57 | char *pszVal = (*papszIter + 41); |
| 58 | char *pszEOL = strchr(pszVal, '\r'); |
| 59 | if (pszEOL) |
| 60 | *pszEOL = 0; |
| 61 | pszEOL = strchr(pszVal, '\n'); |
| 62 | if (pszEOL) |
| 63 | *pszEOL = 0; |
| 64 | return SanitizeDispositionFilename(pszVal); |
| 65 | } |
| 66 | papszIter++; |
| 67 | } |
| 68 | return std::string(); |
| 69 | } |
| 70 | |
| 71 | /************************************************************************/ |
| 72 | /* HTTPOpen() */ |
no test coverage detected