curl-users
Mime type on uploaded file
Date: Tue, 15 Apr 2003 12:16:52 +0300
Dear Friends,
I am using curl to upload HTML files to the w3c validation service at
validator.w3.org/check, i.e.
curl -F uploaded_file=@index.html http://validator.w3.org/check
However, I get the response
Sorry, I am unable to validate this document because its content type is
text/plain, which is not currently supported by this service.
Checking the origin of that using the --trace option of curl, I found out that
curl adds this "text/plain" content type to the uploaded file. This is a part
of the trace (up to the start of the html file):
<= Recv header, 23 bytes (0x17)
0000: 48 54 54 50 2f 31 2e 31 20 31 30 30 20 43 6f 6e HTTP/1.1 100 Con
0010: 74 69 6e 75 65 0d 0a tinue..
=> Send data, 5165 bytes (0x142d)
0000: 2d 2d 63 75 72 6c 32 4c 53 74 66 69 59 59 71 4f --curl2LStfiYYqO
0010: 36 5a 6d 67 78 55 72 44 55 7a 4e 4e 6d 69 65 54 6ZmgxUrDUzNNmieT
0020: 4a 0d 0a 43 6f 6e 74 65 6e 74 2d 44 69 73 70 6f J..Content-Dispo
0030: 73 69 74 69 6f 6e 3a 20 66 6f 72 6d 2d 64 61 74 sition: form-dat
0040: 61 3b 20 6e 61 6d 65 3d 22 75 70 6c 6f 61 64 65 a; name="uploade
0050: 64 5f 66 69 6c 65 22 3b 20 66 69 6c 65 6e 61 6d d_file"; filenam
0060: 65 3d 22 69 6e 64 65 78 2e 68 74 6d 6c 22 0d 0a e="index.html"..
0070: 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 Content-Type: te
0080: 78 74 2f 70 6c 61 69 6e 0d 0a 0d 0a 3c 21 44 4f xt/plain....<!DO
0090: 43 54 59 50 45 20 48 54 4d 4c 20 50 55 42 4c 49 CTYPE HTML PUBLI
00a0: 43 20 22 2d 2f 2f 57 33 43 2f 2f 44 54 44 20 48 C "-//W3C//DTD H
00b0: 54 4d 4c 20 34 2e 30 31 20 54 72 61 6e 73 69 74 TML 4.01 Transit
00c0: 69 6f 6e 61 6c 2f 2f 45 4e 22 3e 0a 3c 48 54 4d ional//EN">.<HTM
If curl cannot identify my index.html file as an html file, from some reason, I
suppose there should be some way to specify the correct mime-type of the
uploaded file! I don't know if you wish to implement all the logic of the
"file" command, but adding a curl option to specify this should be quicker.
There might already be such an option, but somehow I didn't find it.
Best,
Zvi.
-- Dr. Zvi Har'El mailto:rl_at_math.technion.ac.il Department of Mathematics tel:+972-54-227607 icq:179294841 Technion - Israel Institute of Technology fax:+972-4-8293388 http://www.math.technion.ac.il/~rl/ Haifa 32000, ISRAEL "If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942) Tuesday, 13 Nisan 5763, 15 April 2003, 11:50AM ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sfReceived on 2003-04-15