skip to Main Content

I am just trying to prepend and append a certain string to Apache responses matching certain filetypes. I thought mod_substitute would do the job, but it errors out all the time with: AH01328: Line too long.

This is what my directive looks like:

<Location "/src">
    AddType application/javascript .txt .tpl
    AddOutputFilter SUBSTITUTE tpl txt
    SubstituteMaxLineLength 10m
    Substitute "s/([sS]*)/export default `$1`/i"
</Location>

As you can see I also tried to up the limit on SubstituteMaxLineLength, but that seems to have no effects.

Any idea what I am doing wrong, or is there another option to solve this seemingly easy (well, apparently not so) task?

2

Answers


  1. Chosen as BEST ANSWER

    Got it resolved by using mod_sed, FYI:

    # this converts the specified file type(s) into ES6 modules by
    # wrapping the response in an "export", so it can be consumed 
    # as a regular string, for example: "import string from 'text.txt'"
    <Location "/src">
        AddType application/javascript .txt .tpl .vue
        AddOutputFilter Sed tpl vue txt
        OutputSed "1s/^/export default `/"
        OutputSed "$s/$/`/"
    </Location>
    

  2. This helped me out, was getting random HTTP error messages regarding Network Timeout / Connection Closed before looking at error_log and seeing the error on mod_substitute.

    I was able to add SubstituteMaxLineLength 10M (with the capital M) and it worked for me.

    Thanks!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search