lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Jun 25, 2014 at 10:14 PM, Austin Einter <austin.einter@gmail.com> wrote:
Hi Luiz
The scriptlooks as below


function modify_content_length(msg, length)

    local offset = string.find(msg, "Content-Length", 1, true)
    if(offset == nil) then
    else
        print("offset = " , offset)
        print(s:gsub("(Content%-Length%s*:%s*)\r","%1"..n.."\r"))    
where did this "s" come from?
 
    end

end

msg = [===["INVITE\r\nContent-Length:\r\n
\r\nv=0\r\n]===]
This wouldn't work. \r and \n aren't interpreted in long strings.

modify_content_length(msg, string.len(msg))


When I execute I get below error

lua5.2: string_test.lua:9: attempt to index global 's' (a nil value)
stack traceback:
    string_test.lua:9: in function 'modify_content_length'
    string_test.lua:18: in main chunk
    [C]: in ?

Regards
Austin





On Thu, Jun 26, 2014 at 7:26 AM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
Try s:gsub("(Content%-Length%s*:%s*)\r","%1"..n.."\r")





--
Sent from my Game Boy.