RTCS HTTP Server: How can I set the file name of a dynamically generated (CGI) file in MQX 4.1?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RTCS HTTP Server: How can I set the file name of a dynamically generated (CGI) file in MQX 4.1?

1,250件の閲覧回数
dmitriyc
Contributor III

Hello,

I am generating a file for download using a CGI function. I found that you can set the file name of the download by modifying the response header. See:

Four Tips for Setting up HTTP File Downloads | HttpWatch Blog

However, according to this thread:

MQX 4.1 HTTPSRV: How to modify the reponse header?

you can no longer manually modify the header.

I'm thinking of modifying he HTTP server code if worst comes to worst, but is there a cleaner way of achieving what I want to do?

ラベル(1)
タグ(4)
4 返答(返信)

964件の閲覧回数
karelm_
Contributor IV

Hi,

Similarly as in thread you mentioned you can use HTML tag <meta http-equiv> see:  how to use | Instructions how to use c - meta tags seo search engines for further information. In your case it would be something like: <meta name="content-disposition" content="attachement; filename=myfilename.ext">

Best regards,

Karel

964件の閲覧回数
dmitriyc
Contributor III

Karel,

Thanks for the reply, but I don't like the idea of using meta tags for this purpose - I will probably try it at some point and see but further googling doesn't paint a good picture for the portability (or even functionality) of this approach. Most people who ask this question are told to use the actual HTTP headers. See here:

Force to open "Save As..." popup open at text link click for pdf in HTML - Stack Overflow

html - Content-disposition or others in http-equiv? - Stack Overflow

Any way I could get a feature request in for this? Maybe if enough people want it, it may happen...

Meanwhile, I put an "extra header" string pointer into the response struct and modified the code that builds the HTTP header accordingly. It ends up being 6 extra lines of code in 4 files which isn't too bad IMO (for a quick hack, anyway). The server code is pretty straightforward in those places. Hopefully I don't need to modify other stuff like this, could get messy...

The only scary part of this was not knowing 100% if the size of the response struct was hardcoded anywhere (which could break things pretty badly)... I'm choosing to assume that such code won't pass any review at Freescale, so that shouldn't be a problem.

964件の閲覧回数
karelm_
Contributor IV

Hi Dmitriy,

I will create a task in our ticket system to allow custom header fields in CGI. As you mentioned it should not be that hard to implement, but it involves change of API (not so good). I will see what I can do.

Best regards,

Karel

963件の閲覧回数
dmitriyc
Contributor III

Karel,

Thank you. I understand the difficulties with API changes. Hopefully it would be easier than usual because something similar was apparently there before, looks like it just got pruned during cleanup/refactoring. In any case, it doesn't hurt for me to ask.

0 件の賞賛