#1 2016-08-26 09:11:16

squirrel
Member
Registered: 2015-08-13
Posts: 155

HTML Status code

Would it be possible to add Html status code 206 (Partial Content) to the list of html status codes as well as to StatusCodeIsSuccess?  This is needed when manually serving files such as audio and video files.

I  added the following to mormot.pas to test:

 /// HTML Status Code for "Partial Content"
  HTML_PARTIALCONTENT = 206;

changed StatusCodeIsSuccess so:

function StatusCodeIsSuccess(Code: integer): boolean;
begin
  case Code of
  HTML_SUCCESS, HTML_NOCONTENT, HTML_CREATED, HTML_PARTIALCONTENT,
  HTML_NOTMODIFIED, HTML_TEMPORARYREDIRECT:
    result := true;
  else
    result := false;
  end;
end;

Also, if anybody has experience with serving audio files to Safari, advice and suggestions would be helpful.  I'm sure I'm missing either a status code or header, but serving the audio files through mormot works with all the browsers except Safari, which sees it as a live broadcast.

Offline

#2 2016-08-26 10:10:59

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: HTML Status code

Offline

#3 2016-08-26 10:35:00

squirrel
Member
Registered: 2015-08-13
Posts: 155

Re: HTML Status code

Looks perfect.  Thanks!

Offline

#4 2016-08-26 11:18:03

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: HTML Status code

From the HTTP POV all status codes >= 200 and <300 is a success status codes. So, may be do in this way (at last such realization is used in all browser-side frameworks):

function StatusCodeIsSuccess(Code: integer): boolean;
begin
  Result := (Code >= HTTP_SUCCESS) and (Code < HTTP_MULTIPLECHOICES);
end;

This is a Angular1 success function:

function isSuccess(status) {
    return 200 <= status && status < 300;
}

Last edited by mpv (2016-08-26 11:23:05)

Offline

#5 2016-08-26 14:33:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: HTML Status code

We consider 300..307 as successful process.
For instance, 304 NOT MODIFIED is a plain successful GET request.

Offline

#6 2016-08-27 10:52:21

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: HTML Status code

Yes, from the Delphi POV 300...307 is a success. I miss it, because from browser side I never got this responses in the JavaScript XHR  - it handled by browser on the low level. So, the final propose is:

function StatusCodeIsSuccess(Code: integer): boolean;
begin
  Result := (Code >= HTTP_SUCCESS) and (Code <= HTTP_TEMPORARYREDIRECT);
end;

Is it OK?

Last edited by mpv (2016-08-27 10:52:45)

Offline

Board footer

Powered by FluxBB