MCPcopy Create free account
hub / github.com/apache/httpd / get_body

Function get_body

modules/mappers/mod_negotiation.c:828–870  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

826}
827
828static apr_off_t get_body(char *buffer, apr_size_t *len, const char *tag,
829 apr_file_t *map)
830{
831 char *endbody;
832 apr_size_t bodylen;
833 apr_off_t pos;
834
835
836 /* We are at the first character following a body:tag\n entry
837 * Suck in the body, then backspace to the first char after the
838 * closing tag entry. If we fail to read, find the tag or back
839 * up then we have a hosed file, so give up already
840 */
841 --*len; /* Reserve space for '\0' */
842 if (apr_file_read(map, buffer, len) != APR_SUCCESS) {
843 return -1;
844 }
845 buffer[*len] = '\0';
846
847 endbody = ap_strstr(buffer, tag);
848 if (!endbody) {
849 return -1;
850 }
851 bodylen = endbody - buffer;
852 endbody += strlen(tag);
853 /* Skip all the trailing cruft after the end tag to the next line */
854 while (*endbody) {
855 if (*endbody == '\n') {
856 ++endbody;
857 break;
858 }
859 ++endbody;
860 }
861
862 pos = -(apr_off_t)(*len - (endbody - buffer));
863 if (apr_file_seek(map, APR_CUR, &pos) != APR_SUCCESS) {
864 return -1;
865 }
866
867 /* Give the caller back the actual body's file offset and length */
868 *len = bodylen;
869 return pos - (endbody - buffer);
870}
871
872
873/* Stripping out RFC822 comments */

Callers 1

read_type_mapFunction · 0.85

Calls 1

ap_strstrFunction · 0.85

Tested by

no test coverage detected