@@ -955,6 +955,9 @@ export const Utils = {
955955 ...pagPlugin
956956 }
957957 ) ;
958+ } else if ( ! paginationHandler . exclusive ) {
959+ // INFO Neither exclusive nor inclusive is set — fall back to plugin-level pagination.
960+ pagPlugin != null && ( result . pagination = { ...pagPlugin } ) ;
958961 }
959962 if ( [ limit , skip , order , sort ] . some ( el => el !== null ) ) {
960963 if ( result . pagination !== null ) {
@@ -1046,7 +1049,9 @@ export const Utils = {
10461049 if ( typeof dataFile . data === "string" ) {
10471050 dataFile . data = JSON . parse ( dataFile . data ) ;
10481051 }
1049- dataFile . originalData = Utils . plugin . cloneData ( dataFile . data ) ;
1052+ if ( dataFile . originalData === null || dataFile . originalData === undefined ) {
1053+ dataFile . originalData = Utils . plugin . cloneData ( dataFile . data ) ;
1054+ }
10501055 const IS_ARRAY = Array . isArray ( dataFile . data ) ;
10511056 if ( ! [ null , undefined ] . includes ( dataFile . data ) ) {
10521057 const { pagination, filters } = this . getPaginationAndFilters ( request , paginationHandler , filtersHandler , paginationPlugin , filtersPlugin ) ;
@@ -1426,8 +1431,15 @@ export const Utils = {
14261431 responseData . headers . forEach ( ( { name, value } ) => {
14271432 res . setHeader ( name , value ) ;
14281433 } ) ;
1434+ const isHead = ( responseData . req as IncomingMessage | undefined ) ?. method === "HEAD" ;
14291435 if ( responseData . data !== this . NO_RESPONSE ) {
1430- res . write ( responseData . data , callbackErrorWritingResponse ) ;
1436+ const serialised = responseData . data as string ;
1437+ res . setHeader ( "content-length" , Buffer . byteLength ( serialised , "utf-8" ) ) ;
1438+ if ( isHead ) {
1439+ endResponse ( ) ;
1440+ } else {
1441+ res . write ( serialised , callbackErrorWritingResponse ) ;
1442+ }
14311443 } else {
14321444 endResponse ( ) ;
14331445 }
0 commit comments