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

Function ssl_io_input_getline

modules/ssl/ssl_engine_io.c:826–878  ·  view source on GitHub ↗

Read a line of input from the SSL input layer into buffer BUF of * length *LEN; updating *len to reflect the length of the line * including the LF character. */

Source from the content-addressed store, hash-verified

824 * length *LEN; updating *len to reflect the length of the line
825 * including the LF character. */
826static apr_status_t ssl_io_input_getline(bio_filter_in_ctx_t *inctx,
827 char *buf,
828 apr_size_t *len)
829{
830 const char *pos = NULL;
831 apr_status_t status;
832 apr_size_t tmplen = *len, buflen = *len, offset = 0;
833
834 *len = 0;
835
836 /*
837 * in most cases we get all the headers on the first SSL_read.
838 * however, in certain cases SSL_read will only get a partial
839 * chunk of the headers, so we try to read until LF is seen.
840 */
841
842 while (tmplen > 0) {
843 status = ssl_io_input_read(inctx, buf + offset, &tmplen);
844
845 if (status != APR_SUCCESS) {
846 if (APR_STATUS_IS_EAGAIN(status) && (*len > 0)) {
847 /* Save the part of the line we already got */
848 char_buffer_write(&inctx->cbuf, buf, *len);
849 }
850 return status;
851 }
852
853 *len += tmplen;
854
855 if ((pos = memchr(buf, APR_ASCII_LF, *len))) {
856 break;
857 }
858
859 offset += tmplen;
860 tmplen = buflen - offset;
861 }
862
863 if (pos) {
864 char *value;
865 int length;
866 apr_size_t bytes = pos - buf;
867
868 bytes += 1;
869 value = buf + bytes;
870 length = *len - bytes;
871
872 char_buffer_write(&inctx->cbuf, value, length);
873
874 *len = bytes;
875 }
876
877 return APR_SUCCESS;
878}
879
880
881static apr_status_t ssl_filter_write(ap_filter_t *f,

Callers 1

ssl_io_filter_inputFunction · 0.85

Calls 2

ssl_io_input_readFunction · 0.85
char_buffer_writeFunction · 0.85

Tested by

no test coverage detected