OL Learn

HTTP Server Input: get encoding in the following workflow

hi there,

first of all thank you all very much. there are many people around here contributing pretty good solutions to all those questions that come up implementing your processes.

i have a question regarding input data coming from the HTTP Server Input node. to my surprise i could not find anything in the forums.

we have implemented a web interface, where visitors input some data, which is then sent to the http server input node as a get-request. the data is then processed in the workflow. everything is fine. almost! :wink:

as we are located in germany, we have to deal with umlauts. so i need to get the encoding from the http-header. how can i do that?

within a python script we are getting the get-parameters from the Watch-object like this (eg parameter ‘order’):


```
    url = '/request[1]/values[1]/order[1]'
    expr = "xmlget('{}', Value, KeepCase, NoTrim)".format(url)
    order = Watch.ExpandString(expr)
```

in that script i would like to parse the xml header of the resulting job file, which is being created by the http server input node.

the header line looks like this:


`<?xml version="1.0" encoding="windows-1252"?>`

using something like '/xml' is not working to be expanded.

i hope i could make clear my point.

any thoughts are greatly appreciated.

thanks in advance,

sebastian

So the original issue is that characters with umlaut aren’t displayed correctly in the result HTTP request\post file?

If so, try the Translator plugin, set the Source encoding to UTF-8 and the Target encoding to 1252 (ANSI - Latin I)

hi rod.

thanks for your answer.

i didnt realize there is a translator-plugin. but im afraid it is not perfectly to the point. only telling by the screenshot it looks like you have to set the encoding in the plugin statically. but as this is a webform, every client using it will have different encodings in place. windows will use cp1252, osx likely to use utf8, and so on. so the workflow has to evaluate some header data to get it right. you cannot guess encodings.

(i have not checked the plugin though, so if there is intelligence in it to analyze header data and react on it, then forget the former paragraph.)

so is the plugin that smart, or do i have to take something else into consideration?

thank you,

sebastian

Every maroon field can be set dynamically using job infos, metadata, local, global and system variables.

yes it is! :slight_smile: but what do i put in there, to evaluate the encoding of the current jobfile? how do i access that piece of information, that is likely to be located in the header line as i mentioned in my initial posting? i guess if i knew the path to that variable, i could access it as well in a script…

thanks for your thoughts!

sebastian

You can proceed as follow:

  • Add a local variable to the process (ex: encodingType or encodingHeader)
  • After the HTTP Server Input, add the “Change Emulation” action and set it to Line Printer
  • Then add the Set Job Infos and Variables and set the Value of the variable encodingType by right-clicking in the box and selecting “Get Data Location” and select the first line which reads: <?xml version=“1.0” encoding=“windows-1252”?>
  • You can then add a Run Script (using RegEX in VBScript, JavaScript or Python) to only extract the encoding value and assign it to your variable.
  • Then Change Emulation back to XML if you want to continue with a XML formatted data.

i see! didnt test it yet, but i understand and think this is it. i am not yet familiar with those emulation changes.

will test this evening.

thanks a lot!

what can i say, amazing. it works. by changing the emulation to lineprinter i have access to the complete jobfile (that is the incoming request).

rod, thanks again.

You are more than welcome, I’m glad I was able to help.

I also stumbled into this problem, but I simply used Search and Replace plugin.
No lineprinter or emulation was needed.