Forum Discussion

andrew_deackes's avatar
andrew_deackes
Icon for Nimbostratus rankNimbostratus
Apr 01, 2020

irule to provide win10 registry file

Hi,

 

as an emergency measure in these difficult times I am using an irule to host a few simple files for remote uses to pick (just some config files for mobile app they usually get when in the office on wifi). I've now been asked to add hosting of a registry file for win10 remote users. The problem I have is that if the content type is "application/octet-stream" then it saves ok, is recognised as a reg file when you run it but it then gives an error:

 

"Cannot import <location file was saved to>audio.reg: The specified file is not a registry script. You can only import binary files from within the registry editor."

 

If I change the irule to use content type of "text/plain" it just displays in the browser rather than saving it.

 

Can anyone suggest how to resolve this? What am I doing wrong?

 

Sanitised version of the irule is as follows:

 

when RULE_INIT { 

set file1 { 

some content

}

set file2 {

some more content

}

set file3 {

even more content

}

set registryfile {

some registry key content

}

}

when HTTP_REQUEST { 

 switch -glob [string tolower [HTTP::uri]] { 

   "/files/file1.txt"

   { HTTP::respond 200 content $::file1 "Content-Type" "text/html" "pragma" "no-cache"}

   "/files/file2.txt"      

  { HTTP::respond 200 content $::file2 "Content-Type" "text/html" "pragma" "no-cache"}

     "/files/file3.txt"      

  { HTTP::respond 200 content $::file3 "Content-Type" "text/html" "pragma" "no-cache"}

     "/registry/win10reg.reg"      

  { HTTP::respond 200 content $::registryfile "Content-Type" "text/plain" "pragma" "no-cache"}

  default

    { HTTP::respond 404 content {Page Not Found} "Content-Type" "text/html" "pragma" "no-cache"}

 

  } 

 }

 

any help appreciated.

 

thanks

 

A

5 Replies

  • Hi Pete,

     

    I'll try with iFiles tomorrow, I've not used them before so will have a read up on that.

     

    It's odd because I thought it would be octet-stream but it shows as text/plain content type when I check with file command on linux:

     

    $ file --mime-type -b win10.reg

    text/plain

    • PeteWhite's avatar
      PeteWhite
      Icon for Employee rankEmployee
      Maybe PM me with the detail of the iRule. Essentially, you have to create it as a binary octet stream but of course you can’t normally store that in a text file ie an iRule – you store a hex representation of it. So you would have to store it in the iRule as hex but convert it to binary before you send it to the client. If you store it as an iFile then that can be stored as binary data and does not need conversion prior to sending to the client.
  • hi Pete,

     

    just to let you know changing to i-file has worked, a much simpler i-rule and having the content-type as application/octet-stream means the reg file downloads and runs fine.

     

    A

    • PeteWhite's avatar
      PeteWhite
      Icon for Employee rankEmployee
      Brilliant! Good job. Take the rest of the day off to celebrate your achievement!