42
42
43
43
typedef struct {
44
44
httpd_conn * hc ;
45
- int read_post_data ;
46
45
void (* on_close )(int );
47
46
48
47
smart_str sbuf ;
@@ -231,41 +230,6 @@ static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC)
231
230
count_bytes -= read_bytes ;
232
231
}
233
232
234
- count_bytes = MIN (count_bytes ,
235
- SG (request_info ).content_length - SG (read_post_bytes ));
236
-
237
- while (read_bytes < count_bytes ) {
238
- tmp = recv (TG (hc )-> conn_fd , buffer + read_bytes ,
239
- count_bytes - read_bytes , 0 );
240
- if (tmp == 0 || (tmp == -1 && errno != EAGAIN ))
241
- break ;
242
- /* A simple "tmp > 0" produced broken code on Solaris/GCC */
243
- if (tmp != 0 && tmp != -1 )
244
- read_bytes += tmp ;
245
-
246
- if (tmp == -1 && errno == EAGAIN ) {
247
- fd_set fdr ;
248
-
249
- FD_ZERO (& fdr );
250
- FD_SET (TG (hc )-> conn_fd , & fdr );
251
- n = select (TG (hc )-> conn_fd + 1 , & fdr , NULL , NULL , NULL );
252
- if (n <= 0 )
253
- php_handle_aborted_connection ();
254
-
255
- continue ;
256
- }
257
- }
258
-
259
- TG (read_post_data ) += read_bytes ;
260
-
261
- /* Hack for user-agents which send a LR or CRLF after POST data */
262
- if (TG (read_post_data ) >= TG (hc )-> contentlength ) {
263
- char tmpbuf [2 ];
264
-
265
- /* we are in non-blocking mode */
266
- recv (TG (hc )-> conn_fd , tmpbuf , 2 , 0 );
267
- }
268
-
269
233
return read_bytes ;
270
234
}
271
235
@@ -471,7 +435,8 @@ static void thttpd_request_ctor(TSRMLS_D)
471
435
SG (request_info ).request_uri = s .c ;
472
436
SG (request_info ).request_method = httpd_method_str (TG (hc )-> method );
473
437
SG (sapi_headers ).http_response_code = 200 ;
474
- SG (request_info ).content_type = TG (hc )-> contenttype ;
438
+ if (TG (hc )-> contenttype )
439
+ SG (request_info ).content_type = strdup (TG (hc )-> contenttype );
475
440
SG (request_info ).content_length = TG (hc )-> contentlength == -1 ? 0
476
441
: TG (hc )-> contentlength ;
477
442
@@ -485,6 +450,8 @@ static void thttpd_request_dtor(TSRMLS_D)
485
450
free (SG (request_info ).query_string );
486
451
free (SG (request_info ).request_uri );
487
452
free (SG (request_info ).path_translated );
453
+ if (SG (request_info ).content_type )
454
+ free (SG (request_info ).content_type );
488
455
}
489
456
490
457
#ifdef ZTS
@@ -664,27 +631,20 @@ static void remove_dead_conn(int fd)
664
631
665
632
#endif
666
633
667
- #define CT_LEN_MAX_RAM 8192
668
-
669
634
static off_t thttpd_real_php_request (httpd_conn * hc , int show_source TSRMLS_DC )
670
635
{
671
636
TG (hc ) = hc ;
672
637
hc -> bytes_sent = 0 ;
673
638
674
- TG (read_post_data ) = 0 ;
675
639
if (hc -> method == METHOD_POST )
676
640
hc -> should_linger = 1 ;
677
641
678
642
if (hc -> contentlength > 0
679
643
&& SIZEOF_UNCONSUMED_BYTES () < hc -> contentlength ) {
680
644
int missing = hc -> contentlength - SIZEOF_UNCONSUMED_BYTES ();
681
645
682
- if (hc -> contentlength < CT_LEN_MAX_RAM ) {
683
- hc -> read_body_into_mem = 1 ;
684
- return 0 ;
685
- } else {
686
- return -1 ;
687
- }
646
+ hc -> read_body_into_mem = 1 ;
647
+ return 0 ;
688
648
}
689
649
690
650
thttpd_request_ctor (TSRMLS_C );
0 commit comments