mORMot and Open Source friends
Check-in [a85d5104b5]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{2891} added HTTP_PARTIALCONTENT status code and renamed rsoHtml200WithNoBodyReturns204 as rsoHttp200WithNoBodyReturns204
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a85d5104b5520bfe1f4a44bfac729bc179aac61e
User & Date: ab 2016-08-26 10:10:36
Context
2016-08-27
09:57
{2892} prevent unexpected branching in SourceCodeRep: - add git pull command to the GitCommit.bat - add optional execution of ("and pull" checkbox) FossilUpdate.bat for fossil pull + fossil update before modifiing SynopseCommit.inc check-in: d58117c865 user: pavel.mash tags: trunk
2016-08-26
10:10
{2891} added HTTP_PARTIALCONTENT status code and renamed rsoHtml200WithNoBodyReturns204 as rsoHttp200WithNoBodyReturns204 check-in: a85d5104b5 user: ab tags: trunk
09:29
{2890} fixed null result returning from nsm_fileStat for Deplhi7 check-in: 92aba07ab3 user: pavel.mash tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to CrossPlatform/SynCrossPlatformSpecific.pas.

255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275


276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  TAbstractHttpConnectionClass = class of TAbstractHttpConnection;


const
  /// MIME content type used for JSON communication
  JSON_CONTENT_TYPE = 'application/json; charset=UTF-8';

  /// HTML Status Code for "Continue"
  HTTP_CONTINUE = 100;
  /// HTML Status Code for "Switching Protocols"
  HTTP_SWITCHINGPROTOCOLS = 101;
  /// HTML Status Code for "Success"
  HTTP_SUCCESS = 200;
  /// HTML Status Code for "Created"
  HTTP_CREATED = 201;
  /// HTML Status Code for "Accepted"
  HTTP_ACCEPTED = 202;
  /// HTML Status Code for "Non-Authoritative Information"
  HTTP_NONAUTHORIZEDINFO = 203;
  /// HTML Status Code for "No Content"
  HTTP_NOCONTENT = 204;


  /// HTML Status Code for "Multiple Choices"
  HTTP_MULTIPLECHOICES = 300;
  /// HTML Status Code for "Moved Permanently"
  HTTP_MOVEDPERMANENTLY = 301;
  /// HTML Status Code for "Found"
  HTTP_FOUND = 302;
  /// HTML Status Code for "See Other"
  HTTP_SEEOTHER = 303;
  /// HTML Status Code for "Not Modified"
  HTTP_NOTMODIFIED = 304;
  /// HTML Status Code for "Use Proxy"
  HTTP_USEPROXY = 305;
  /// HTML Status Code for "Temporary Redirect"
  HTTP_TEMPORARYREDIRECT = 307;
  /// HTML Status Code for "Bad Request"
  HTTP_BADREQUEST = 400;
  /// HTML Status Code for "Unauthorized"
  HTTP_UNAUTHORIZED = 401;
  /// HTML Status Code for "Forbidden"
  HTTP_FORBIDDEN = 403;
  /// HTML Status Code for "Not Found"
  HTTP_NOTFOUND = 404;
  // HTML Status Code for "Method Not Allowed"
  HTTP_NOTALLOWED = 405;
  // HTML Status Code for "Not Acceptable"
  HTTP_NOTACCEPTABLE = 406;
  // HTML Status Code for "Proxy Authentication Required"
  HTTP_PROXYAUTHREQUIRED = 407;
  /// HTML Status Code for "Request Time-out"
  HTTP_TIMEOUT = 408;
  /// HTML Status Code for "Internal Server Error"
  HTTP_SERVERERROR = 500;
  /// HTML Status Code for "Not Implemented"
  HTTP_NOTIMPLEMENTED = 501;
  /// HTML Status Code for "Bad Gateway"
  HTTP_BADGATEWAY = 502;
  /// HTML Status Code for "Service Unavailable"
  HTTP_UNAVAILABLE = 503;
  /// HTML Status Code for "Gateway Timeout"
  HTTP_GATEWAYTIMEOUT = 504;
  /// HTML Status Code for "HTTP Version Not Supported"
  HTTP_HTTPVERSIONNONSUPPORTED = 505;


/// gives access to the class type to implement a HTTP connection
// - will use WinHTTP API (from our SynCrtSock) under Windows
// - will use Indy for Delphi on other platforms
// - will use fcl-web (fphttpclient) with FreePascal






|

|

|

|

|

|

|

>
>
|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
  TAbstractHttpConnectionClass = class of TAbstractHttpConnection;


const
  /// MIME content type used for JSON communication
  JSON_CONTENT_TYPE = 'application/json; charset=UTF-8';

  /// HTTP Status Code for "Continue"
  HTTP_CONTINUE = 100;
  /// HTTP Status Code for "Switching Protocols"
  HTTP_SWITCHINGPROTOCOLS = 101;
  /// HTTP Status Code for "Success"
  HTTP_SUCCESS = 200;
  /// HTTP Status Code for "Created"
  HTTP_CREATED = 201;
  /// HTTP Status Code for "Accepted"
  HTTP_ACCEPTED = 202;
  /// HTTP Status Code for "Non-Authoritative Information"
  HTTP_NONAUTHORIZEDINFO = 203;
  /// HTTP Status Code for "No Content"
  HTTP_NOCONTENT = 204;
  /// HTTP Status Code for "Partial Content"
  HTTP_PARTIALCONTENT = 206;
  /// HTTP Status Code for "Multiple Choices"
  HTTP_MULTIPLECHOICES = 300;
  /// HTTP Status Code for "Moved Permanently"
  HTTP_MOVEDPERMANENTLY = 301;
  /// HTTP Status Code for "Found"
  HTTP_FOUND = 302;
  /// HTTP Status Code for "See Other"
  HTTP_SEEOTHER = 303;
  /// HTTP Status Code for "Not Modified"
  HTTP_NOTMODIFIED = 304;
  /// HTTP Status Code for "Use Proxy"
  HTTP_USEPROXY = 305;
  /// HTTP Status Code for "Temporary Redirect"
  HTTP_TEMPORARYREDIRECT = 307;
  /// HTTP Status Code for "Bad Request"
  HTTP_BADREQUEST = 400;
  /// HTTP Status Code for "Unauthorized"
  HTTP_UNAUTHORIZED = 401;
  /// HTTP Status Code for "Forbidden"
  HTTP_FORBIDDEN = 403;
  /// HTTP Status Code for "Not Found"
  HTTP_NOTFOUND = 404;
  // HTTP Status Code for "Method Not Allowed"
  HTTP_NOTALLOWED = 405;
  // HTTP Status Code for "Not Acceptable"
  HTTP_NOTACCEPTABLE = 406;
  // HTTP Status Code for "Proxy Authentication Required"
  HTTP_PROXYAUTHREQUIRED = 407;
  /// HTTP Status Code for "Request Time-out"
  HTTP_TIMEOUT = 408;
  /// HTTP Status Code for "Internal Server Error"
  HTTP_SERVERERROR = 500;
  /// HTTP Status Code for "Not Implemented"
  HTTP_NOTIMPLEMENTED = 501;
  /// HTTP Status Code for "Bad Gateway"
  HTTP_BADGATEWAY = 502;
  /// HTTP Status Code for "Service Unavailable"
  HTTP_UNAVAILABLE = 503;
  /// HTTP Status Code for "Gateway Timeout"
  HTTP_GATEWAYTIMEOUT = 504;
  /// HTTP Status Code for "HTTP Version Not Supported"
  HTTP_HTTPVERSIONNONSUPPORTED = 505;


/// gives access to the class type to implement a HTTP connection
// - will use WinHTTP API (from our SynCrtSock) under Windows
// - will use Indy for Delphi on other platforms
// - will use fcl-web (fphttpclient) with FreePascal

Changes to SQLite3/mORMot.pas.

4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593


4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
....
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
.....
15663
15664
15665
15666
15667
15668
15669
15670
15671

15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
.....
22991
22992
22993
22994
22995
22996
22997

22998
22999
23000
23001
23002
23003
23004
.....
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
.....
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
    function LoadFromFile(const jsonfile: TFileName): boolean;
  published
    /// returns all certificates information as a base-64 encoded text array
    property PublicBase64: variant read GetPublicBase64;
  end;

const
  /// HTML Status Code for "Continue"
  HTTP_CONTINUE = 100;
  /// HTML Status Code for "Switching Protocols"
  HTTP_SWITCHINGPROTOCOLS = 101;
  /// HTML Status Code for "Success"
  HTTP_SUCCESS = 200;
  /// HTML Status Code for "Created"
  HTTP_CREATED = 201;
  /// HTML Status Code for "Accepted"
  HTTP_ACCEPTED = 202;
  /// HTML Status Code for "Non-Authoritative Information"
  HTTP_NONAUTHORIZEDINFO = 203;
  /// HTML Status Code for "No Content"
  HTTP_NOCONTENT = 204;


  /// HTML Status Code for "Multiple Choices"
  HTTP_MULTIPLECHOICES = 300;
  /// HTML Status Code for "Moved Permanently"
  HTTP_MOVEDPERMANENTLY = 301;
  /// HTML Status Code for "Found"
  HTTP_FOUND = 302;
  /// HTML Status Code for "See Other"
  HTTP_SEEOTHER = 303;
  /// HTML Status Code for "Not Modified"
  HTTP_NOTMODIFIED = 304;
  /// HTML Status Code for "Use Proxy"
  HTTP_USEPROXY = 305;
  /// HTML Status Code for "Temporary Redirect"
  HTTP_TEMPORARYREDIRECT = 307;
  /// HTML Status Code for "Bad Request"
  HTTP_BADREQUEST = 400;
  /// HTML Status Code for "Unauthorized"
  HTTP_UNAUTHORIZED = 401;
  /// HTML Status Code for "Forbidden"
  HTTP_FORBIDDEN = 403;
  /// HTML Status Code for "Not Found"
  HTTP_NOTFOUND = 404;
  // HTML Status Code for "Method Not Allowed"
  HTTP_NOTALLOWED = 405;
  // HTML Status Code for "Not Acceptable"
  HTTP_NOTACCEPTABLE = 406;
  // HTML Status Code for "Proxy Authentication Required"
  HTTP_PROXYAUTHREQUIRED = 407;
  /// HTML Status Code for "Request Time-out"
  HTTP_TIMEOUT = 408;
  /// HTML Status Code for "Internal Server Error"
  HTTP_SERVERERROR = 500;
  /// HTML Status Code for "Not Implemented"
  HTTP_NOTIMPLEMENTED = 501;
  /// HTML Status Code for "Bad Gateway"
  HTTP_BADGATEWAY = 502;
  /// HTML Status Code for "Service Unavailable"
  HTTP_UNAVAILABLE = 503;
  /// HTML Status Code for "Gateway Timeout"
  HTTP_GATEWAYTIMEOUT = 504;
  /// HTML Status Code for "HTTP Version Not Supported"
  HTTP_HTTPVERSIONNONSUPPORTED = 505;

  /// you can use this cookie value to delete a cookie on the browser side
  COOKIE_EXPIRED = '; Expires=Sat, 01 Jan 2010 00:00:01 GMT';

  /// used e.g. by THttpApiServer.Request for http.sys to send a static file
  // - the OutCustomHeader should contain the proper 'Content-type: ....'
................................................................................
procedure StatusCodeToErrorMsg(Code: integer; var result: RawUTF8); overload;

/// convert any HTTP_* constant to an integer error code and its English text
// - see @http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
function StatusCodeToErrorMsg(Code: integer): RawUTF8; overload;

/// returns true for SUCCESS (200), CREATED (201), NOCONTENT (204),
// NOTMODIFIED (304) or TEMPORARYREDIRECT (307) codes
function StatusCodeIsSuccess(Code: integer): boolean;
  {$ifdef HASINLINE}inline;{$endif}

type
  /// the available HTTP methods transmitted between client and server
  // - some custom verbs are available in addition to standard REST commands
  // - most of iana verbs are available
................................................................................
  // limitation of 53-bit for integers - only for AJAX (non Delphi) clients
  // - unauthenticated requests from browsers (i.e. not Delphi clients) may
  // be redirected to the TSQLRestServer.Auth() method via rsoRedirectForbiddenToAuth
  // (e.g. for TSQLRestServerAuthenticationHttpBasic popup)
  // - some REST/AJAX clients may expect to return status code 204 as
  // instead of 200 in case of a successful operation, but with no returned
  // body (e.g. a DELETE with SAPUI5 / OpenUI5 framework): include
  // rsoHtml200WithNoBodyReturns204 so that any HTTP_SUCCESS (200) with no
  // returned body would return a HTTP_NOCONTENT (204)

  // - by default, Add() or Update() would return HTTP_CREATED (201) or
  // HTTP_SUCCESS (200) with no body, unless rsoAddUpdateReturnsContent is set
  // to return as JSON the last inserted/updated record
  // - TModTime / TCreateTime fields are expected to be filled on client side,
  // unless you set rsoComputeFieldsBeforeWriteOnServerSide so that AJAX requests
  // would set the fields on the server side by calling the TSQLRecord
  // ComputeFieldsBeforeWrite virtual method, before writing to the database
  TSQLRestServerOption = (
    rsoNoAJAXJSON,
    rsoGetAsJsonNotAsString,
    rsoGetID_str,
    rsoRedirectForbiddenToAuth,
    rsoHtml200WithNoBodyReturns204,
    rsoAddUpdateReturnsContent,
    rsoComputeFieldsBeforeWriteOnServerSide);
  /// allow to customize the TSQLRestServer process via its Options property
  TSQLRestServerOptions = set of TSQLRestServerOption;

  /// a generic REpresentational State Transfer (REST) server
  // - descendent must implement the protected EngineList() Retrieve() Add()
................................................................................
    HTTP_CONTINUE:            result := 'Continue';
    HTTP_SWITCHINGPROTOCOLS:  result := 'Switching Protocols';
    HTTP_SUCCESS:             result := 'OK';
    HTTP_CREATED:             result := 'Created';
    HTTP_ACCEPTED:            result := 'Accepted';
    HTTP_NONAUTHORIZEDINFO:   result := 'Non-Authoritative Information';
    HTTP_NOCONTENT:           result := 'No Content';

    HTTP_MULTIPLECHOICES:     result := 'Multiple Choices';
    HTTP_MOVEDPERMANENTLY:    result := 'Moved Permanently';
    HTTP_FOUND:               result := 'Found';
    HTTP_SEEOTHER:            result := 'See Other';
    HTTP_NOTMODIFIED:         result := 'Not Modified';
    HTTP_USEPROXY:            result := 'Use Proxy';
    HTTP_TEMPORARYREDIRECT:   result := 'Temporary Redirect';
................................................................................
  StatusCodeToErrorMsg(Code,result);
  result := FormatUTF8('HTTP Error % - %',[Code,result]);
end;

function StatusCodeIsSuccess(Code: integer): boolean;
begin
  case Code of
  HTTP_SUCCESS, HTTP_NOCONTENT, HTTP_CREATED,
  HTTP_NOTMODIFIED, HTTP_TEMPORARYREDIRECT:
    result := true;
  else
    result := false;
  end;
end;

................................................................................
      outcomingfile := false;
      if Call.OutBody<>'' then begin
        len := length(Call.OutHead);
        outcomingfile := (len>=25) and (Call.OutHead[15]='!') and
          IdemPChar(pointer(Call.OutHead),STATICFILE_CONTENT_TYPE_HEADER_UPPPER);
      end else // Call.OutBody=''
        if (Call.OutStatus=HTTP_SUCCESS) and
           (rsoHtml200WithNoBodyReturns204 in fOptions) then
          Call.OutStatus := HTTP_NOCONTENT;
      fStats.ProcessSuccess(outcomingfile);
    end else begin
      fStats.ProcessErrorNumber(Call.OutStatus);
      if Call.OutBody='' then // if no custom error message, compute it now as JSON
        Ctxt.Error(Ctxt.CustomErrorMsg,Call.OutStatus);
    end;






|

|

|

|

|

|

|

>
>
|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|







 







|







 







|
|
>












|







 







>







 







|







 







|







4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
....
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
.....
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
.....
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
.....
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
.....
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
    function LoadFromFile(const jsonfile: TFileName): boolean;
  published
    /// returns all certificates information as a base-64 encoded text array
    property PublicBase64: variant read GetPublicBase64;
  end;

const
  /// HTTP Status Code for "Continue"
  HTTP_CONTINUE = 100;
  /// HTTP Status Code for "Switching Protocols"
  HTTP_SWITCHINGPROTOCOLS = 101;
  /// HTTP Status Code for "Success"
  HTTP_SUCCESS = 200;
  /// HTTP Status Code for "Created"
  HTTP_CREATED = 201;
  /// HTTP Status Code for "Accepted"
  HTTP_ACCEPTED = 202;
  /// HTTP Status Code for "Non-Authoritative Information"
  HTTP_NONAUTHORIZEDINFO = 203;
  /// HTTP Status Code for "No Content"
  HTTP_NOCONTENT = 204;
  /// HTTP Status Code for "Partial Content"
  HTTP_PARTIALCONTENT = 206;
    /// HTTP Status Code for "Multiple Choices"
  HTTP_MULTIPLECHOICES = 300;
  /// HTTP Status Code for "Moved Permanently"
  HTTP_MOVEDPERMANENTLY = 301;
  /// HTTP Status Code for "Found"
  HTTP_FOUND = 302;
  /// HTTP Status Code for "See Other"
  HTTP_SEEOTHER = 303;
  /// HTTP Status Code for "Not Modified"
  HTTP_NOTMODIFIED = 304;
  /// HTTP Status Code for "Use Proxy"
  HTTP_USEPROXY = 305;
  /// HTTP Status Code for "Temporary Redirect"
  HTTP_TEMPORARYREDIRECT = 307;
  /// HTTP Status Code for "Bad Request"
  HTTP_BADREQUEST = 400;
  /// HTTP Status Code for "Unauthorized"
  HTTP_UNAUTHORIZED = 401;
  /// HTTP Status Code for "Forbidden"
  HTTP_FORBIDDEN = 403;
  /// HTTP Status Code for "Not Found"
  HTTP_NOTFOUND = 404;
  // HTTP Status Code for "Method Not Allowed"
  HTTP_NOTALLOWED = 405;
  // HTTP Status Code for "Not Acceptable"
  HTTP_NOTACCEPTABLE = 406;
  // HTTP Status Code for "Proxy Authentication Required"
  HTTP_PROXYAUTHREQUIRED = 407;
  /// HTTP Status Code for "Request Time-out"
  HTTP_TIMEOUT = 408;
  /// HTTP Status Code for "Internal Server Error"
  HTTP_SERVERERROR = 500;
  /// HTTP Status Code for "Not Implemented"
  HTTP_NOTIMPLEMENTED = 501;
  /// HTTP Status Code for "Bad Gateway"
  HTTP_BADGATEWAY = 502;
  /// HTTP Status Code for "Service Unavailable"
  HTTP_UNAVAILABLE = 503;
  /// HTTP Status Code for "Gateway Timeout"
  HTTP_GATEWAYTIMEOUT = 504;
  /// HTTP Status Code for "HTTP Version Not Supported"
  HTTP_HTTPVERSIONNONSUPPORTED = 505;

  /// you can use this cookie value to delete a cookie on the browser side
  COOKIE_EXPIRED = '; Expires=Sat, 01 Jan 2010 00:00:01 GMT';

  /// used e.g. by THttpApiServer.Request for http.sys to send a static file
  // - the OutCustomHeader should contain the proper 'Content-type: ....'
................................................................................
procedure StatusCodeToErrorMsg(Code: integer; var result: RawUTF8); overload;

/// convert any HTTP_* constant to an integer error code and its English text
// - see @http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
function StatusCodeToErrorMsg(Code: integer): RawUTF8; overload;

/// returns true for SUCCESS (200), CREATED (201), NOCONTENT (204),
// PARTIALCONTENT (206), NOTMODIFIED (304) or TEMPORARYREDIRECT (307) codes
function StatusCodeIsSuccess(Code: integer): boolean;
  {$ifdef HASINLINE}inline;{$endif}

type
  /// the available HTTP methods transmitted between client and server
  // - some custom verbs are available in addition to standard REST commands
  // - most of iana verbs are available
................................................................................
  // limitation of 53-bit for integers - only for AJAX (non Delphi) clients
  // - unauthenticated requests from browsers (i.e. not Delphi clients) may
  // be redirected to the TSQLRestServer.Auth() method via rsoRedirectForbiddenToAuth
  // (e.g. for TSQLRestServerAuthenticationHttpBasic popup)
  // - some REST/AJAX clients may expect to return status code 204 as
  // instead of 200 in case of a successful operation, but with no returned
  // body (e.g. a DELETE with SAPUI5 / OpenUI5 framework): include
  // rsoHttp200WithNoBodyReturns204 so that any HTTP_SUCCESS (200) with no
  // returned body would return a HTTP_NOCONTENT (204), as expected by
  // some clients
  // - by default, Add() or Update() would return HTTP_CREATED (201) or
  // HTTP_SUCCESS (200) with no body, unless rsoAddUpdateReturnsContent is set
  // to return as JSON the last inserted/updated record
  // - TModTime / TCreateTime fields are expected to be filled on client side,
  // unless you set rsoComputeFieldsBeforeWriteOnServerSide so that AJAX requests
  // would set the fields on the server side by calling the TSQLRecord
  // ComputeFieldsBeforeWrite virtual method, before writing to the database
  TSQLRestServerOption = (
    rsoNoAJAXJSON,
    rsoGetAsJsonNotAsString,
    rsoGetID_str,
    rsoRedirectForbiddenToAuth,
    rsoHttp200WithNoBodyReturns204,
    rsoAddUpdateReturnsContent,
    rsoComputeFieldsBeforeWriteOnServerSide);
  /// allow to customize the TSQLRestServer process via its Options property
  TSQLRestServerOptions = set of TSQLRestServerOption;

  /// a generic REpresentational State Transfer (REST) server
  // - descendent must implement the protected EngineList() Retrieve() Add()
................................................................................
    HTTP_CONTINUE:            result := 'Continue';
    HTTP_SWITCHINGPROTOCOLS:  result := 'Switching Protocols';
    HTTP_SUCCESS:             result := 'OK';
    HTTP_CREATED:             result := 'Created';
    HTTP_ACCEPTED:            result := 'Accepted';
    HTTP_NONAUTHORIZEDINFO:   result := 'Non-Authoritative Information';
    HTTP_NOCONTENT:           result := 'No Content';
    HTTP_PARTIALCONTENT:      result := 'Partial Content';
    HTTP_MULTIPLECHOICES:     result := 'Multiple Choices';
    HTTP_MOVEDPERMANENTLY:    result := 'Moved Permanently';
    HTTP_FOUND:               result := 'Found';
    HTTP_SEEOTHER:            result := 'See Other';
    HTTP_NOTMODIFIED:         result := 'Not Modified';
    HTTP_USEPROXY:            result := 'Use Proxy';
    HTTP_TEMPORARYREDIRECT:   result := 'Temporary Redirect';
................................................................................
  StatusCodeToErrorMsg(Code,result);
  result := FormatUTF8('HTTP Error % - %',[Code,result]);
end;

function StatusCodeIsSuccess(Code: integer): boolean;
begin
  case Code of
  HTTP_SUCCESS, HTTP_NOCONTENT, HTTP_PARTIALCONTENT, HTTP_CREATED,
  HTTP_NOTMODIFIED, HTTP_TEMPORARYREDIRECT:
    result := true;
  else
    result := false;
  end;
end;

................................................................................
      outcomingfile := false;
      if Call.OutBody<>'' then begin
        len := length(Call.OutHead);
        outcomingfile := (len>=25) and (Call.OutHead[15]='!') and
          IdemPChar(pointer(Call.OutHead),STATICFILE_CONTENT_TYPE_HEADER_UPPPER);
      end else // Call.OutBody=''
        if (Call.OutStatus=HTTP_SUCCESS) and
           (rsoHttp200WithNoBodyReturns204 in fOptions) then
          Call.OutStatus := HTTP_NOCONTENT;
      fStats.ProcessSuccess(outcomingfile);
    end else begin
      fStats.ProcessErrorNumber(Call.OutStatus);
      if Call.OutBody='' then // if no custom error message, compute it now as JSON
        Ctxt.Error(Ctxt.CustomErrorMsg,Call.OutStatus);
    end;

Changes to SQLite3/mORMotMVC.pas.

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  // so that TServiceMethod.InternalExecute() would handle it directly
  TMVCAction = record
    /// the method name to be executed
    RedirectToMethodName: RawUTF8;
    /// may contain a JSON object which will be used to specify parameters
    // to the specified method
    RedirectToMethodParameters: RawUTF8;
    /// which HTML status code should be returned
    // - if RedirectMethodName is set, will return 307 HTTP_TEMPORARYREDIRECT
    // by default, but you can set here the expected HTML status code, e.g.
    // 201 HTTP_CREATED or 404 HTTP_NOTFOUND
    ReturnedStatus: cardinal;
  end;

  TMVCApplication = class;

  /// abtract MVC rendering execution context






|

|







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
  // so that TServiceMethod.InternalExecute() would handle it directly
  TMVCAction = record
    /// the method name to be executed
    RedirectToMethodName: RawUTF8;
    /// may contain a JSON object which will be used to specify parameters
    // to the specified method
    RedirectToMethodParameters: RawUTF8;
    /// which HTTP Status code should be returned
    // - if RedirectMethodName is set, will return 307 HTTP_TEMPORARYREDIRECT
    // by default, but you can set here the expected HTTP Status code, e.g.
    // 201 HTTP_CREATED or 404 HTTP_NOTFOUND
    ReturnedStatus: cardinal;
  end;

  TMVCApplication = class;

  /// abtract MVC rendering execution context

Changes to SynBidirSock.pas.

508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
    /// finalize the context
    // - will release the TWebSocketProtocol associated instance
    destructor Destroy; override;
    /// will push a request or notification to the other end of the connection
    // - caller should set the aRequest with the outgoing parameters, and
    // optionally receive a response from the other end
    // - the request may be sent in blocking or non blocking mode
    // - returns the HTML status code (HTTP_SUCCESS=200 for success)
    function NotifyCallback(aRequest: THttpServerRequest;
      aMode: TWebSocketProcessNotifyCallback): cardinal; virtual;
    /// the settings currently used during the WebSockets process
    // - defined as a pointer so that you may be able to change the values
    function Settings: PWebSocketProcessSettings; {$ifdef HASINLINE}inline;{$endif}
    /// the associated communication socket
    // - on the server side, is a THttpServerSocket






|







508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
    /// finalize the context
    // - will release the TWebSocketProtocol associated instance
    destructor Destroy; override;
    /// will push a request or notification to the other end of the connection
    // - caller should set the aRequest with the outgoing parameters, and
    // optionally receive a response from the other end
    // - the request may be sent in blocking or non blocking mode
    // - returns the HTTP Status code (e.g. HTTP_SUCCESS=200 for success)
    function NotifyCallback(aRequest: THttpServerRequest;
      aMode: TWebSocketProcessNotifyCallback): cardinal; virtual;
    /// the settings currently used during the WebSockets process
    // - defined as a pointer so that you may be able to change the values
    function Settings: PWebSocketProcessSettings; {$ifdef HASINLINE}inline;{$endif}
    /// the associated communication socket
    // - on the server side, is a THttpServerSocket

Changes to SynCrtSock.pas.

1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
/// convert a supplied subject text into an Unicode encoding
// - will convert the text into UTF-8 and append '=?UTF-8?B?'
// - for pre-Unicode versions of Delphi, Text is expected to be already UTF-8
// encoded - since Delphi 2010, it will be converted from UnicodeString
function SendEmailSubject(const Text: string): SockString;

const
  /// HTML Status Code for "Success"
  STATUS_SUCCESS = 200;
  /// HTML Status Code for "Created"
  STATUS_CREATED = 201;
  /// HTML Status Code for "No Content"
  STATUS_NOCONTENT = 204;
  /// HTML Status Code for "Bad Request"
  STATUS_BADREQUEST = 400;
  /// HTML Status Code for "Unauthorized"
  STATUS_UNAUTHORIZED = 401;
  /// HTML Status Code for "Forbidden"
  STATUS_FORBIDDEN = 403;
  /// HTML Status Code for "Not Found"
  STATUS_NOTFOUND = 404;
  /// HTML Status Code for "Internal Server Error"
  STATUS_SERVERERROR = 500;
  /// HTML Status Code for "Not Implemented"
  STATUS_NOTIMPLEMENTED = 501;

  {$ifdef MSWINDOWS}
  /// can be used with THttpApiServer.AuthenticationSchemes to enable all schemes
  HTTPAPI_AUTH_ENABLE_ALL = [hraBasic..hraKerberos];
  {$endif}







|

|

|

|

|

|

|

|

|







1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
/// convert a supplied subject text into an Unicode encoding
// - will convert the text into UTF-8 and append '=?UTF-8?B?'
// - for pre-Unicode versions of Delphi, Text is expected to be already UTF-8
// encoded - since Delphi 2010, it will be converted from UnicodeString
function SendEmailSubject(const Text: string): SockString;

const
  /// HTTP Status Code for "Success"
  STATUS_SUCCESS = 200;
  /// HTTP Status Code for "Created"
  STATUS_CREATED = 201;
  /// HTTP Status Code for "No Content"
  STATUS_NOCONTENT = 204;
  /// HTTP Status Code for "Bad Request"
  STATUS_BADREQUEST = 400;
  /// HTTP Status Code for "Unauthorized"
  STATUS_UNAUTHORIZED = 401;
  /// HTTP Status Code for "Forbidden"
  STATUS_FORBIDDEN = 403;
  /// HTTP Status Code for "Not Found"
  STATUS_NOTFOUND = 404;
  /// HTTP Status Code for "Internal Server Error"
  STATUS_SERVERERROR = 500;
  /// HTTP Status Code for "Not Implemented"
  STATUS_NOTIMPLEMENTED = 501;

  {$ifdef MSWINDOWS}
  /// can be used with THttpApiServer.AuthenticationSchemes to enable all schemes
  HTTPAPI_AUTH_ENABLE_ALL = [hraBasic..hraKerberos];
  {$endif}

Changes to SynopseCommit.inc.

1
'1.18.2890'
|
1
'1.18.2891'