MCPcopy Create free account
hub / github.com/OpenPrinting/cups / httpGetContentEncoding

Function httpGetContentEncoding

cups/http.c:831–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

829 */
830
831const char * /* O - Content-Coding value or
832 @code NULL@ for the identity
833 coding. */
834httpGetContentEncoding(http_t *http) /* I - HTTP connection */
835{
836#ifdef HAVE_LIBZ
837 if (http && http->fields[HTTP_FIELD_ACCEPT_ENCODING])
838 {
839 int i; /* Looping var */
840 char temp[HTTP_MAX_VALUE], /* Copy of Accepts-Encoding value */
841 *start, /* Start of coding value */
842 *end; /* End of coding value */
843 double qvalue; /* "qvalue" for coding */
844 struct lconv *loc = localeconv(); /* Locale data */
845 static const char * const codings[] =
846 { /* Supported content codings */
847 "deflate",
848 "gzip",
849 "x-deflate",
850 "x-gzip"
851 };
852
853 strlcpy(temp, http->fields[HTTP_FIELD_ACCEPT_ENCODING], sizeof(temp));
854
855 for (start = temp; *start; start = end)
856 {
857 /*
858 * Find the end of the coding name...
859 */
860
861 qvalue = 1.0;
862 end = start;
863 while (*end && *end != ';' && *end != ',' && !isspace(*end & 255))
864 end ++;
865
866 if (*end == ';')
867 {
868 /*
869 * Grab the qvalue as needed...
870 */
871
872 if (!strncmp(end, ";q=", 3))
873 qvalue = _cupsStrScand(end + 3, NULL, loc);
874
875 /*
876 * Skip past all attributes...
877 */
878
879 *end++ = '\0';
880 while (*end && *end != ',' && !isspace(*end & 255))
881 end ++;
882 }
883 else if (*end)
884 *end++ = '\0';
885
886 while (*end && isspace(*end & 255))
887 end ++;
888

Callers 1

mainFunction · 0.85

Calls 1

_cupsStrScandFunction · 0.85

Tested by 1

mainFunction · 0.68