@@ -4,14 +4,14 @@ use std::ops::{Deref, DerefMut};
4
4
use std:: slice;
5
5
use std:: str;
6
6
7
-
8
7
use parking_lot:: { const_rwlock, RwLock , RwLockReadGuard , RwLockWriteGuard } ;
9
8
10
9
use crate :: boxed:: ZBox ;
11
10
use crate :: ffi:: {
12
- _zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_process_globals, ext_php_rs_sapi_globals,
13
- php_core_globals, sapi_globals_struct, TRACK_VARS_COOKIE , TRACK_VARS_ENV , TRACK_VARS_FILES , TRACK_VARS_GET ,
14
- TRACK_VARS_POST , TRACK_VARS_REQUEST , TRACK_VARS_SERVER , sapi_request_info, zend_is_auto_global, sapi_headers_struct, sapi_header_struct
11
+ _zend_executor_globals, ext_php_rs_executor_globals, ext_php_rs_process_globals,
12
+ ext_php_rs_sapi_globals, php_core_globals, sapi_globals_struct, sapi_header_struct,
13
+ sapi_headers_struct, sapi_request_info, zend_is_auto_global, TRACK_VARS_COOKIE , TRACK_VARS_ENV ,
14
+ TRACK_VARS_FILES , TRACK_VARS_GET , TRACK_VARS_POST , TRACK_VARS_REQUEST , TRACK_VARS_SERVER ,
15
15
} ;
16
16
17
17
use crate :: types:: { ZendHashTable , ZendObject , ZendStr } ;
@@ -112,10 +112,9 @@ impl ProcessGlobals {
112
112
113
113
/// Get the HTTP Server variables. Equivalent of $_SERVER.
114
114
pub fn http_server_vars ( & self ) -> Option < & ZendHashTable > {
115
-
116
115
// $_SERVER is lazy-initted, we need to call zend_is_auto_global
117
116
// if it's not already populated.
118
- if ! self . http_globals [ TRACK_VARS_SERVER as usize ] . is_array ( ) {
117
+ if !self . http_globals [ TRACK_VARS_SERVER as usize ] . is_array ( ) {
119
118
let name = ZendStr :: new ( "_SERVER" , false ) . as_mut_ptr ( ) ;
120
119
unsafe { zend_is_auto_global ( name) } ;
121
120
}
@@ -169,7 +168,6 @@ impl ProcessGlobals {
169
168
}
170
169
}
171
170
172
-
173
171
/// Stores global variables used in the SAPI.
174
172
pub type SapiGlobals = sapi_globals_struct ;
175
173
@@ -208,7 +206,7 @@ impl SapiGlobals {
208
206
& self . request_info
209
207
}
210
208
211
- pub fn sapi_headers ( & self ) -> & SapiHeaders {
209
+ pub fn sapi_headers ( & self ) -> & SapiHeaders {
212
210
& self . sapi_headers
213
211
}
214
212
}
@@ -247,27 +245,21 @@ impl SapiRequestInfo {
247
245
if self . request_method . is_null ( ) {
248
246
return None ;
249
247
}
250
- unsafe {
251
- CStr :: from_ptr ( self . request_method ) . to_str ( ) . ok ( )
252
- }
248
+ unsafe { CStr :: from_ptr ( self . request_method ) . to_str ( ) . ok ( ) }
253
249
}
254
250
255
251
pub fn query_string ( & self ) -> Option < & str > {
256
252
if self . query_string . is_null ( ) {
257
253
return None ;
258
254
}
259
- unsafe {
260
- CStr :: from_ptr ( self . query_string ) . to_str ( ) . ok ( )
261
- }
255
+ unsafe { CStr :: from_ptr ( self . query_string ) . to_str ( ) . ok ( ) }
262
256
}
263
257
264
258
pub fn cookie_data ( & self ) -> Option < & str > {
265
259
if self . cookie_data . is_null ( ) {
266
260
return None ;
267
261
}
268
- unsafe {
269
- CStr :: from_ptr ( self . cookie_data ) . to_str ( ) . ok ( )
270
- }
262
+ unsafe { CStr :: from_ptr ( self . cookie_data ) . to_str ( ) . ok ( ) }
271
263
}
272
264
273
265
pub fn content_length ( & self ) -> i64 {
@@ -278,18 +270,14 @@ impl SapiRequestInfo {
278
270
if self . path_translated . is_null ( ) {
279
271
return None ;
280
272
}
281
- unsafe {
282
- CStr :: from_ptr ( self . path_translated ) . to_str ( ) . ok ( )
283
- }
273
+ unsafe { CStr :: from_ptr ( self . path_translated ) . to_str ( ) . ok ( ) }
284
274
}
285
275
286
276
pub fn request_uri ( & self ) -> Option < & str > {
287
277
if self . request_uri . is_null ( ) {
288
278
return None ;
289
279
}
290
- unsafe {
291
- CStr :: from_ptr ( self . request_uri ) . to_str ( ) . ok ( )
292
- }
280
+ unsafe { CStr :: from_ptr ( self . request_uri ) . to_str ( ) . ok ( ) }
293
281
}
294
282
295
283
// Todo: request_body _php_stream
@@ -298,9 +286,7 @@ impl SapiRequestInfo {
298
286
if self . content_type . is_null ( ) {
299
287
return None ;
300
288
}
301
- unsafe {
302
- CStr :: from_ptr ( self . content_type ) . to_str ( ) . ok ( )
303
- }
289
+ unsafe { CStr :: from_ptr ( self . content_type ) . to_str ( ) . ok ( ) }
304
290
}
305
291
306
292
pub fn headers_only ( & self ) -> bool {
@@ -321,45 +307,35 @@ impl SapiRequestInfo {
321
307
if self . auth_user . is_null ( ) {
322
308
return None ;
323
309
}
324
- unsafe {
325
- CStr :: from_ptr ( self . auth_user ) . to_str ( ) . ok ( )
326
- }
310
+ unsafe { CStr :: from_ptr ( self . auth_user ) . to_str ( ) . ok ( ) }
327
311
}
328
312
329
313
pub fn auth_password ( & self ) -> Option < & str > {
330
314
if self . auth_password . is_null ( ) {
331
315
return None ;
332
316
}
333
- unsafe {
334
- CStr :: from_ptr ( self . auth_password ) . to_str ( ) . ok ( )
335
- }
317
+ unsafe { CStr :: from_ptr ( self . auth_password ) . to_str ( ) . ok ( ) }
336
318
}
337
319
338
320
pub fn auth_digest ( & self ) -> Option < & str > {
339
321
if self . auth_digest . is_null ( ) {
340
322
return None ;
341
323
}
342
- unsafe {
343
- CStr :: from_ptr ( self . auth_digest ) . to_str ( ) . ok ( )
344
- }
324
+ unsafe { CStr :: from_ptr ( self . auth_digest ) . to_str ( ) . ok ( ) }
345
325
}
346
326
347
327
pub fn argv0 ( & self ) -> Option < & str > {
348
328
if self . argv0 . is_null ( ) {
349
329
return None ;
350
330
}
351
- unsafe {
352
- CStr :: from_ptr ( self . argv0 ) . to_str ( ) . ok ( )
353
- }
331
+ unsafe { CStr :: from_ptr ( self . argv0 ) . to_str ( ) . ok ( ) }
354
332
}
355
333
356
334
pub fn current_user ( & self ) -> Option < & str > {
357
335
if self . current_user . is_null ( ) {
358
336
return None ;
359
337
}
360
- unsafe {
361
- CStr :: from_ptr ( self . current_user ) . to_str ( ) . ok ( )
362
- }
338
+ unsafe { CStr :: from_ptr ( self . current_user ) . to_str ( ) . ok ( ) }
363
339
}
364
340
365
341
pub fn current_user_length ( & self ) -> i32 {
@@ -374,15 +350,12 @@ impl SapiRequestInfo {
374
350
if self . argv . is_null ( ) {
375
351
return None ;
376
352
}
377
- unsafe {
378
- CStr :: from_ptr ( * self . argv ) . to_str ( ) . ok ( )
379
- }
353
+ unsafe { CStr :: from_ptr ( * self . argv ) . to_str ( ) . ok ( ) }
380
354
}
381
355
382
356
pub fn proto_num ( & self ) -> i32 {
383
357
self . proto_num
384
358
}
385
-
386
359
}
387
360
388
361
/// Executor globals rwlock.
0 commit comments