      SUBROUTINE PLW.GET.HTTP.HDR(ERR.FLG)
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      ERR.FLG = NO
*
      ST$CMD = ''
      ST$HTTP.HDR = ''
      ST$HTTP.VAL = ''
*
      LOOP
         PL_TCP_READ D FROM ST$PLCB , 2000 ELSE
            ERR.FLG = YES
            RETURN
         END
*
*$*      D = D<1>
         IF D = '' THEN RETURN
*
         ST$IBUF = ST$IBUF : D
*
         IF LEN(ST$IBUF) > PLIP$MAX.HTTP.HDR THEN
            ERR.FLG = YES
            RETURN
         END
*
         LOOP WHILE ST$IBUF[1,1] = LF DO
            ST$IBUF = ST$IBUF[2,BIG.STR]
         REPEAT
         LOOP WHILE ST$IBUF[1,2] = CRLF DO
            ST$IBUF = ST$IBUF[3,BIG.STR]
         REPEAT
*
         T = INDEX(ST$IBUF,LF:LF,1)
         IF T = 0 THEN T = INDEX(ST$IBUF,CRLF:CRLF,1)
*
      UNTIL T DO REPEAT
*
      S = ST$IBUF[1,T-1]
      S = PL_REPL(S,CR,'')
      S = PL_REPL(S,LF,AM)
*
      ST$IBUF = ST$IBUF[T,BIG.STR]
      BEGIN CASE
         CASE ST$IBUF[1,2] = LF : LF
            ST$IBUF = ST$IBUF[3,BIG.STR]
         CASE ST$IBUF[1,4] = CRLF : CRLF
            ST$IBUF = ST$IBUF[5,BIG.STR]
      END CASE
*
      ST$CMD = S<1>
      I1 = DCOUNT(S,AM)
      FOR I = 2 TO I1
         SS = S<I>
         GOSUB 100
      NEXT I
*
      RETURN
*
100   REM Process header line SS
*
      C = OCONV(TRIM(FIELD(SS,':',1)),'MCU')
      W = PL_TRIMF(PL_TRIMB(OCONV(SS,'G1:9999')))
      LOCATE(C,ST$HTTP.HDR,1;LOC;'AL') THEN
         ST$HTTP.VAL<1,LOC,-1> = W
      END ELSE
         ST$HTTP.HDR = INSERT(ST$HTTP.HDR,1,LOC,0,C)
         ST$HTTP.VAL = INSERT(ST$HTTP.VAL,1,LOC,0,W)
      END
*
      RETURN
   END
