Shop OBEX P1 Docs P2 Docs Learn Events
Bug/Misbehave in HttpHeader.spin W5100/W5200 — Parallax Forums

Bug/Misbehave in HttpHeader.spin W5100/W5200

msrobotsmsrobots Posts: 3,709
edited 2013-08-23 18:58 in Propeller 1
The Tokenizer of HttpHeader.spin is to rigorous.

The value / is allowed in url-parameter.

some things need to change (its easy)

locate
PRI IsStatusLineToken(value)
   return lookdown(value & $FF: "/", "?", "=", "+", " ", "&")
replace with
PRI IsStatusLineToken(value)
  return lookdown(value & $FF:  "?", "=", "+", " ", "&")

locate
PUB GetFileName | i, j
  repeat i from 1 to sectionTokenCnt[STATUS_LINE]-2
    t1 := tokenPtr[i]
    repeat j from 0 to strsize(t1)-1
      if(byte[t1][j] == ".")
        return tokenPtr[i]
  return @index
replace with
PUB GetFileName 
  return tokenPtr[1]

locate
PRI _GetFileNameExtension | I, j     
  repeat i from 1 to sectionTokenCnt[STATUS_LINE]-2
    t1 := tokenPtr[i]
    repeat j from 0 to strsize(t1)-1
      if(byte[t1][j] == ".")
        return tokenPtr[i]+j+1
  return @index + strsize(@index)-FILE_EXTENSION_LEN   
replace with
PRI _GetFileNameExtension | j
  t1 := tokenPtr[1]  
  repeat j from strsize(t1)-6 to strsize(t1)-1
    if(byte[t1][j] == ".")
      return tokenPtr[1]+j+1      
  return @index + strsize(@index)-FILE_EXTENSION_LEN 

This will allow '/' inside of url-params and also allows files without extension and directories with extension (both problematic before)

the returned filename now includes the path as expected by the sd-driver

Enjoy!

Mike
Sign In or Register to comment.