Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Perl: разработка для Web > Парам. name в Content-Type


Автор: Адреналина 25.7.2003, 15:37
Почему когда я отсылаю файл броузеру msie он не хочет давать файлу имя, кот. я прописываю в параметре name:
print "Content-type: application/x-fucking-type; name=\"report.doc\"\n\n";
,а предлагает следующее имя: имя_скрипта.cgi

Автор: Cepera 25.8.2003, 19:49
Цитата
"Content-type: application/x-fucking-type; name=\"report.doc\"\n\n";

а объясните мне , что это за тип такой?

Автор: Nobody 25.8.2003, 19:54
Да нету такого типа. Я вообще не понимаю, откуда он это взял.

Автор: Cepera 25.8.2003, 20:06
уважаемый Nobody, ваш предыдущий пост я удалил, будьте, пожалуйста, более корректны
я думаю, что люди, если задают вопрос, то хотят услышать на него ответ, а не пространные рассуждения, что де есть бог и де есть сатана

Автор: Nobody 25.8.2003, 20:12
Мдя... Ну хорошо, то же самое можно сказать и более приземленными словами. Експлорер предлагает сохранять файлы под теми именами, какой УРЛ у них и есть. И ничто это не изменит.

Автор: Cepera 25.8.2003, 20:16
хех... а как насчет генерируемых файлов?smile.gif
в данном случае это именно так и выходит...
я, кстати, очень часто так делаю в своих скриптах, при бекапе бд имена генерятся из имени бд + текущей даты

Автор: MuToGeN 26.8.2003, 09:55
Content-disposition: inline; filename="my_file.txt"
Вроде как-то так
Цитата
Експлорер предлагает сохранять файлы под теми именами, какой УРЛ у них и есть. И ничто это не изменит.
Nobody, позвольте с вами не согласиться...

Автор: NightGoblin 31.8.2003, 06:17
А что за Content-description? в HTTP 1.1 такого нет... confused.gif

Автор: MuToGeN 1.9.2003, 09:06
Ошибся... Content-disposition, вроде. Короче, где-то тут (или в PHP) оно уже обсуждалось....

Автор: NightGoblin 4.9.2003, 23:02
Выдержка из RFC 2068 "Hypertext Transfer Protocol -- HTTP/1.1"

Цитата

7.1 Entity Header Fields
...
          entity-header  = Allow                    ; Section 14.7             
                        | Content-Base            ; Section 14.11           
                        | Content-Encoding        ; Section 14.12           
                        | Content-Language        ; Section 14.13           
                        | Content-Length          ; Section 14.14           
                        | Content-Location        ; Section 14.15           
                        | Content-MD5              ; Section 14.16           
                        | Content-Range            ; Section 14.17           
                        | Content-Type            ; Section 14.18           
                        | ETag                    ; Section 14.20           
                        | Expires                  ; Section 14.21           
                        | Last-Modified            ; Section 14.29           
                        | extension-header                                   


То есть, в самом HTTP/1.1 ничего подобного нет... Однако, далее следует вот что:

Цитата

          extension-header = message-header                                   
                                                                               
  The extension-header mechanism allows additional entity-header fields       
  to be defined without changing the protocol, but these fields cannot       
  be assumed to be recognizable by the recipient. Unrecognized header         
  fields SHOULD be ignored by the recipient and forwarded by proxies.         


т. е., заголовок типа Content-desposition (или как его уже там) - уже не часть протоола HTTP, а фантазия некоторой фирмы, не имеющей отношения к W3C, а потому таких вещей, ИМХО, следует избегать. Ну конечно, если вы не разрабатываете замечательные сайты "IE Only".

Автор: MuToGeN 5.9.2003, 09:12
Цитата
Выдержка из RFC 2068 "Hypertext Transfer Protocol -- HTTP/1.1"
Выдержка из RFC 2616 "Hypertext Transfer Protocol -- HTTP/1.1":
Цитата
...Obsoletes: 2068...
Цитата
15.5 Content-Disposition Issues

   RFC 1806 [35], from which the often implemented Content-Disposition
   (see section 19.5.1) header in HTTP is derived, has a number of very
   serious security considerations. Content-Disposition is not part of
   the HTTP standard, but since it is widely implemented, we are
   documenting its use and risks for implementors. See RFC 2183 [49]
   (which updates RFC 1806) for details.
Цитата
19.5.1 Content-Disposition

   The Content-Disposition response-header field has been proposed as a
   means for the origin server to suggest a default filename if the user
   requests that the content is saved to a file. This usage is derived
   from the definition of Content-Disposition in RFC 1806 [35].

        content-disposition = "Content-Disposition" ":"
                              disposition-type *( ";" disposition-parm )
        disposition-type = "attachment" | disp-extension-token
        disposition-parm = filename-parm | disp-extension-parm
        filename-parm = "filename" "=" quoted-string
        disp-extension-token = token
        disp-extension-parm = token "=" ( token | quoted-string )

   An example is

        Content-Disposition: attachment; filename="fname.ext"

   The receiving user agent SHOULD NOT respect any directory path
   information present in the filename-parm parameter, which is the only
   parameter believed to apply to HTTP implementations at this time. The
   filename SHOULD be treated as a terminal component only.

   If this header is used in a response with the application/octet-
   stream content-type, the implied suggestion is that the user agent
   should not display the response, but directly enter a `save response
   as...' dialog.

   See section 15.5 for Content-Disposition security issues.

Автор: MuToGeN 5.9.2003, 09:16
Кстати, тогда тоже ошибся... Не Content-desposition, а Content-disposition

Автор: GoodBoy 9.9.2003, 12:48
Попробуйте вот так:

print "Content-Type: type/subtype\n";
print "Content-Disposition: attachment; filename=\"$file_name\"\n\n";

my $buff = '';
open(F, "<$path/$file");
while (read (F, $buff, 1024)) { print STDOUT $buff; }
close F;

у меня работает...

Автор: NightGoblin 10.9.2003, 04:58
Цитата(MuToGeN @ 5.9.2003, 06:12)
Выдержка из RFC 2616 "Hypertext Transfer Protocol -- HTTP/1.1"

hmmm.gif кстати, спасибо за инфу - пригодится wink.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)