Re: Correct value of parameter uploaded_file

I get html result whether I add output=soap12 or not. My function is
 
        private void ValidateFile(string urlOfTool, string fileToValidate)
        {
            string boundary = "----------------------------" +
DateTime.Now.Ticks.ToString("x");
 
            string data = "--" + boundary + "\r\n";
            //data += "Content-Disposition: form-data; name=\"output\"\r\n";
            //data += "soap12" + "\r\n";
            //data += "--" + boundary + "\r\n";
            data += "Content-Disposition: form-data; name=\"uploaded_file\";
filename=\"" + fileToValidate + "\"\r\n";
            data += "Content-Type: text/html\r\n";
 
            byte[] dataByte = System.Text.Encoding.UTF8.GetBytes(data);
            byte[] fileByte = System.IO.File.ReadAllBytes(fileToValidate);
            byte[] end = System.Text.Encoding.UTF8.GetBytes("\r\n--" +
boundary + "--\r\n");
 
            HttpWebRequest httpWebRequest =
(HttpWebRequest)WebRequest.Create(urlOfTool);
            httpWebRequest.ContentType = "multipart/form-data; boundary=" +
boundary;
            httpWebRequest.Method = "POST";
            httpWebRequest.KeepAlive = true;
            httpWebRequest.Credentials =
System.Net.CredentialCache.DefaultCredentials;
            httpWebRequest.ContentLength = dataByte.Length + fileByte.Length
+ end.Length;
 
            Stream requestStream = httpWebRequest.GetRequestStream();
            requestStream.Write(dataByte, 0, dataByte.Length);
            requestStream.Write(fileByte, 0, fileByte.Length);
            requestStream.Write(end, 0, end.Length);
            requestStream.Flush();
            requestStream.Close();
 
            WebResponse webResponse = httpWebRequest.GetResponse();
 
System.IO.File.WriteAllText("C:\\Users\\Erdal\\Desktop\\sonuc.html", new
StreamReader(webResponse.GetResponseStream()).ReadToEnd());
            webResponse.Close();
        }
 
 
When I uncomment output=soap12 part, again html results returns.
 
            data += "Content-Disposition: form-data; name=\"output\"\r\n";
            data += "soap12" + "\r\n";
            data += "--" + boundary + "\r\n";
 
 
What is wrong about my function? I call function as below:
 

        private void button1_Click(object sender, EventArgs e)

        {

            string urlOfTool = "http://validator.w3.org/check";

            string fileToValidate =
"D:\\master\\Tez\\Proje\\ACTToolOfWA\\Output\\3a8c9ca4-6ebd-46f7-b7a4-1e573a
63d229.html";

            ValidateFile(urlOfTool, fileToValidate);

        }

 
 
On Saturday 04 December 2010, Mehmet Erdal ÖZKINACI wrote:
> What about "output=soap12" for xml result in multipart/form-data POST?
> 
> I wrote a code which sent multipart/form-data POST for Validate by File
> Upload validation mode. It works and returns html result from
> validator.w3.org
> 
> but I cannot get xml result.
 
What *do* you get when requesting it?
 
> Is there any help?
> 
> And sometimes I get prolog error. Why?
 
Make sure that your code sends the filename parameter for the Content-
Disposition header for your uploaded_file field.  Validator gets confused if

that parameter is not present.
 
The development version now becomes less confused and treats cases without
the 
filename parameter as if they had been fragment POSTs, see today's changes
at 
http://dvcs.w3.org/hg/markup-validator/

 

Received on Monday, 6 December 2010 08:14:28 UTC