rejetto forum

Author Topic: My questions regarding HFS  (Read 13668 times)

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 2059
    • View Profile
Re: My questions regarding HFS
« on: May 17, 2016, 01:25:58 PM »
I do not know how far it is possible to modify the response header but there is a macro for it

Quote
    if name = 'add header' then
      if satisfied(md.cd) then
        begin
        result:='';
        // macro 'mime' should be used for content-type, but this test will save precious time to those who will be fooled by the presence this macro
        if ansiStartsText('Content-Type:', p) then
          md.cd.conn.reply.contentType:=trim(substr(p, ':'))
        else if ansiStartsText('Location:', p) then
          with md.cd.conn.reply do
            begin
            mode:=HRM_REDIRECT;
            url:=trim(substr(p, ':'))
            end
        else
          md.cd.conn.addHeader(p);
        end;

procedure ThttpConn.addHeader(s:string; overwrite:boolean=TRUE);
var
    i, j: integer;
    name: string;
begin
if overwrite then
    begin
    // calculate the matching text
    i:=pos(':', s);
    if i = 0 then
        i:=length(s);
    name:=copy(s, 1, i);
    // see if it already exists
    i:=ipos(name, reply.additionalHeaders);
    if (i = 1) or (s[i-1] = #10) then // yes it does
        begin
        j:=posEx(#10, s, i)+1; 
        delete(s, i, j-i+1); // remove it                         
        end;
    end;
reply.additionalHeaders:=reply.additionalHeaders+s+CRLF;
end;

as default in the macro, each content of the header can be overridden

there is more to do tests to examine changes at the browser  ;)

Follow members gave a thank to your post:


Thank-o-Matic 3.0 By Adk Team