curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: Fwd: Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.

From: Ray Satiro via curl-users <curl-users_at_cool.haxx.se>
Date: Wed, 10 May 2017 01:14:17 -0400

On 5/9/2017 6:52 PM, Reynard Harrison via curl-users wrote:
>
> Hello Bagdar and Jay,
>
>
>
> Thank you for even responding to my post well, to be honest, I don’t
> even know what to call my app it work like soapUI
> (https://www.soapui.org/#_ga=2.231068255.1796044353.1494342082-2037242614.1494342082
> <https://mail.gmgtransport.com/owa/redir.aspx?SURL=ZKrAFeN0IvFzmR9q8cz6h3fBG3Xn-DImkZxK_zh0d2VZskbaI5fUCGgAdAB0AHAAcwA6AC8ALwB3AHcAdwAuAHMAbwBhAHAAdQBpAC4AbwByAGcALwAjAF8AZwBhAD0AMgAuADIAMwAxADAANgA4ADIANQA1AC4AMQA3ADkANgAwADQANAAzADUAMwAuADEANAA5ADQAMwA0ADIAMAA4ADIALQAyADAAMwA3ADIANAAyADYAMQA0AC4AMQA0ADkANAAzADQAMgAwADgAMgA.&URL=https%3a%2f%2fwww.soapui.org%2f%23_ga%3d2.231068255.1796044353.1494342082-2037242614.1494342082>)
> I have been fighting with this thing for 2 weeks. Every soap call
> works and Rest call works. The only time the app does not work is when
> the username and password have to be in the property. I have made the
> changes that jay recommend thank you, however, I received a different
> error. Here is the entire code for the app.
>
>
>

As I mentioned in the bug report you filed [1] , curl-users is the wrong
mailing list for this question. Please subscribe to curl-library and
then reply to this e-mail on that list. I'm CCing curl-library.

Also when you have a problem like this, ideally we need a *minimal* self
contained example that can be used to reproduce the issue. There is a
lot of code in your e-mail [2], most of it not relevant.

>
>
> What Curl send :
>
>
>
> * STATE: INIT => CONNECT handle 0x2b4c0b0; line 1402 (connection #-5000)
>
> * Added connection 0. The cache now contains 1 members
>
> * STATE: CONNECT => WAITRESOLVE handle 0x2b4c0b0; line 1439
> (connection #0)
>
> * Trying 23.36.92.238...
>
> * STATE: WAITRESOLVE => WAITCONNECT handle 0x2b4c0b0; line 1520
> (connection #0)
>
> * Connected to www.odfl.com
> <https://mail.gmgtransport.com/owa/redir.aspx?SURL=4gu2F9xm-O3QLoS2aasMTgXcLDp9XNtg2Wu3Cz-60KCoFEnaI5fUCGgAdAB0AHAAOgAvAC8AdwB3AHcALgBvAGQAZgBsAC4AYwBvAG0A&URL=http%3a%2f%2fwww.odfl.com> (23.36.92.238)
> port 80 (#0)
>
> * STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x2b4c0b0; line 1562
> (connection
>
> #0)
>
> * STATE: SENDPROTOCONNECT => DO handle 0x2b4c0b0; line 1580
> (connection #0)
>
> > POST /TraceWebServiceWeb/services/Trace HTTP/1.1
>
> Host: www.odfl.com
> <https://mail.gmgtransport.com/owa/redir.aspx?SURL=4gu2F9xm-O3QLoS2aasMTgXcLDp9XNtg2Wu3Cz-60KCoFEnaI5fUCGgAdAB0AHAAOgAvAC8AdwB3AHcALgBvAGQAZgBsAC4AYwBvAG0A&URL=http%3a%2f%2fwww.odfl.com>
>
> User-Agent: libcurl-agent/1.0
>
> Accept: */*
>
> Accept-Encoding: gzip,deflate
>
> Content-Type: text/xml;charset=UTF-8
>
> Transfer-Encoding: gzip
>
> Content-Length: 32767
>
> Expect: 100-continue
>
>
>
> * STATE: DO => DO_DONE handle 0x2b4c0b0; line 1659 (connection #0)
>
> * STATE: DO_DONE => WAITPERFORM handle 0x2b4c0b0; line 1786
> (connection #0)
>
> * STATE: WAITPERFORM => PERFORM handle 0x2b4c0b0; line 1796
> (connection #0)
>
> * HTTP 1.1 or later with persistent connection, pipelining supported
>
> < HTTP/1.1 400 Bad Request
>
> * Server Oracle-HTTP-Server-12c is not blacklisted
>
> < Server: Oracle-HTTP-Server-12c
>
> < Vary: Accept-Encoding
>
> < Content-Type: text/html; charset=iso-8859-1
>
> < Date: Tue, 09 May 2017 14:51:08 GMT
>
> < Connection: close
>
> < Set-Cookie: DCID=DC1
>
> < Set-Cookie:
> NSC_MCWT_Psbdmf_xxx.pegm.dpn-80=ffffffffaf17e46945525d5f4f58455e44
>
> 5a4a4229a0;Version=1;Max-Age=3600;path=/;httponly
>
> <
>
> * nread <= 0, server closed connection, bailing
>
> * STATE: PERFORM => DONE handle 0x2b4c0b0; line 1955 (connection #0)
>
> * multi_done
>
> * Closing connection 0
>
> * The cache now contains 0 members
>
> * Expire cleared
>
>
>
> Result :
>
>
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
>
> <html><head>
>
> <title>302 Found</title>
>
> </head><body>
>
> <h1>Found</h1>
>
> <p>The request could not be understood by server due to
>
> malformed syntax.</p>
>
> <p>Additionally, a 400 Bad Request
>
> error was encountered while trying to use an ErrorDocument to handle
> the request.</p>
>
> </body></html>
>
>
>

The code you posted [2] is now modified from what you represented in the
report you filed [1], and so there are new problems.

First problem: You are now sending the wrong size content length
"Content-Length: 32767". You are setting CURLOPT_POSTFIELDSIZE_LARGE
apparently to the max size of your request buffer. As I explained in the
report you filed, open the xml input file as binary (inpfile -- you are
already doing this), get the file size, and pass that to
CURLOPT_POSTFIELDSIZE_LARGE.

Second problem: You are now sending request header "Transfer-Encoding:
gzip". Frankly I've never heard of that being used as a request header
but I guess it's possible? What server supports gzipped request from a
client that way? I doubt you are using that properly (like 99%), I would
remove it.

Generally I think you have been using these compression headers wrong
and that's causing you a lot of pain. There should be no reason to set
either Transfer-Encoding or Accept-Encoding as gzip. As I mentioned in
the report I suggest you use an empty string with
CURLOPT_ACCEPT_ENCODING [3], and libcurl will automatically send an
Accept-Encoding header with all supported encodings. If your libcurl
doesn't support gzip then it isn't sent in the header. Your server
supports gzipped content encoded replies for some SOAP so if you do it
that way you can get gzipped replies automatically decompressed by libcurl.

As for your username/password problem I don't understand how that has
anything to do with this.

[1]: https://github.com/curl/curl/issues/1473
[2]: https://curl.haxx.se/mail/archive-2017-05/0025.html
[3]: https://curl.haxx.se/libcurl/c/CURLOPT_ACCEPT_ENCODING.html

-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-05-10