hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arūnas Bendoraitis (JIRA) <j...@apache.org>
Subject [jira] [Commented] (HTTPCORE-342) 'expect-continue' issue.
Date Wed, 29 May 2013 14:47:20 GMT

    [ https://issues.apache.org/jira/browse/HTTPCORE-342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13669317#comment-13669317
] 

Arūnas Bendoraitis commented on HTTPCORE-342:
---------------------------------------------

Ok, so I'm using compiled jar's of httpcore and httpclient from the current trunk's (httpclient-4.3-beta2-SNAPSHOT,
httpcore-4.3-beta3-SNAPSHOT).

This is complete sample code which I'm running:

{code:java}
    public static void main(String[] args) throws Exception
    {
        java.util.logging.Logger.getLogger("org.apache.http.wire").setLevel(java.util.logging.Level.FINEST);
        java.util.logging.Logger.getLogger("org.apache.http.headers").setLevel(java.util.logging.Level.FINEST);
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
        System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "DEBUG");;
        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "DEBUG");
        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.headers",
"DEBUG");

        HttpClient httpclient = new DecompressingHttpClient();

        final List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("vb_login_username", "12testasd127"));
        params.add(new BasicNameValuePair("vb_login_password", "12testasd127"));

        HttpPost httpPost = new HttpPost("http://www.majaa.net/login.php?do=login");
        httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));

        HttpResponse response = httpclient.execute(httpPost);

        System.out.println(response.getStatusLine().getStatusCode());
    }
{code}

This is the output:
{code}
2013/05/29 17:46:19:028 EEST [DEBUG] BasicClientConnectionManager - Get connection for route
{}->http://www.majaa.net
2013/05/29 17:46:19:043 EEST [DEBUG] DefaultClientConnectionOperator - Connecting to www.majaa.net:80
2013/05/29 17:46:19:210 EEST [DEBUG] RequestAddCookies - CookieSpec selected: best-match
2013/05/29 17:46:19:224 EEST [DEBUG] RequestAuthCache - Auth cache not set in the context
2013/05/29 17:46:19:224 EEST [DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
2013/05/29 17:46:19:225 EEST [DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
2013/05/29 17:46:19:225 EEST [DEBUG] DefaultHttpClient - Attempt 1 to execute request
2013/05/29 17:46:19:225 EEST [DEBUG] DefaultClientConnection - Sending request: POST /login.php?do=login
HTTP/1.1
2013/05/29 17:46:19:226 EEST [DEBUG] wire -  >> "POST /login.php?do=login HTTP/1.1[\r][\n]"
2013/05/29 17:46:19:227 EEST [DEBUG] wire -  >> "Accept-Encoding: gzip,deflate[\r][\n]"
2013/05/29 17:46:19:227 EEST [DEBUG] wire -  >> "Content-Length: 61[\r][\n]"
2013/05/29 17:46:19:227 EEST [DEBUG] wire -  >> "Content-Type: application/x-www-form-urlencoded;
charset=UTF-8[\r][\n]"
2013/05/29 17:46:19:227 EEST [DEBUG] wire -  >> "Host: www.majaa.net[\r][\n]"
2013/05/29 17:46:19:227 EEST [DEBUG] wire -  >> "Connection: Keep-Alive[\r][\n]"
2013/05/29 17:46:19:228 EEST [DEBUG] wire -  >> "User-Agent: Apache-HttpClient/4.3-beta2-SNAPSHOT
(java 1.5)[\r][\n]"
2013/05/29 17:46:19:228 EEST [DEBUG] wire -  >> "Expect: 100-continue[\r][\n]"
2013/05/29 17:46:19:228 EEST [DEBUG] wire -  >> "[\r][\n]"
2013/05/29 17:46:19:228 EEST [DEBUG] headers - >> POST /login.php?do=login HTTP/1.1
2013/05/29 17:46:19:228 EEST [DEBUG] headers - >> Accept-Encoding: gzip,deflate
2013/05/29 17:46:19:228 EEST [DEBUG] headers - >> Content-Length: 61
2013/05/29 17:46:19:228 EEST [DEBUG] headers - >> Content-Type: application/x-www-form-urlencoded;
charset=UTF-8
2013/05/29 17:46:19:229 EEST [DEBUG] headers - >> Host: www.majaa.net
2013/05/29 17:46:19:229 EEST [DEBUG] headers - >> Connection: Keep-Alive
2013/05/29 17:46:19:229 EEST [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.3-beta2-SNAPSHOT
(java 1.5)
2013/05/29 17:46:19:230 EEST [DEBUG] headers - >> Expect: 100-continue
2013/05/29 17:46:19:359 EEST [DEBUG] wire -  << "HTTP/1.1 417 Expectation Failed[\r][\n]"
2013/05/29 17:46:19:363 EEST [DEBUG] wire -  << "Content-Type: text/html[\r][\n]"
2013/05/29 17:46:19:364 EEST [DEBUG] wire -  << "Content-Length: 363[\r][\n]"
2013/05/29 17:46:19:364 EEST [DEBUG] wire -  << "Connection: close[\r][\n]"
2013/05/29 17:46:19:364 EEST [DEBUG] wire -  << "Date: Wed, 29 May 2013 07:19:21 GMT[\r][\n]"
2013/05/29 17:46:19:365 EEST [DEBUG] wire -  << "Server: lighttpd/1.4.31[\r][\n]"
2013/05/29 17:46:19:365 EEST [DEBUG] wire -  << "[\r][\n]"
2013/05/29 17:46:19:367 EEST [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1
417 Expectation Failed
2013/05/29 17:46:19:367 EEST [DEBUG] headers - << HTTP/1.1 417 Expectation Failed
2013/05/29 17:46:19:367 EEST [DEBUG] headers - << Content-Type: text/html
2013/05/29 17:46:19:367 EEST [DEBUG] headers - << Content-Length: 363
2013/05/29 17:46:19:367 EEST [DEBUG] headers - << Connection: close
2013/05/29 17:46:19:368 EEST [DEBUG] headers - << Date: Wed, 29 May 2013 07:19:21 GMT
2013/05/29 17:46:19:368 EEST [DEBUG] headers - << Server: lighttpd/1.4.31
417
{code}

This is the output (which is expected by me) if I revert the revision (58760a12132862d1cc284585415a1440f2a1317b)
locally and build httpcore jar:

{code}
2013/05/29 17:38:47:454 EEST [DEBUG] BasicClientConnectionManager - Get connection for route
{}->http://www.majaa.net
2013/05/29 17:38:47:469 EEST [DEBUG] DefaultClientConnectionOperator - Connecting to www.majaa.net:80
2013/05/29 17:38:47:634 EEST [DEBUG] RequestAddCookies - CookieSpec selected: best-match
2013/05/29 17:38:47:643 EEST [DEBUG] RequestAuthCache - Auth cache not set in the context
2013/05/29 17:38:47:644 EEST [DEBUG] RequestTargetAuthentication - Target auth state: UNCHALLENGED
2013/05/29 17:38:47:644 EEST [DEBUG] RequestProxyAuthentication - Proxy auth state: UNCHALLENGED
2013/05/29 17:38:47:644 EEST [DEBUG] DefaultHttpClient - Attempt 1 to execute request
2013/05/29 17:38:47:644 EEST [DEBUG] DefaultClientConnection - Sending request: POST /login.php?do=login
HTTP/1.1
2013/05/29 17:38:47:645 EEST [DEBUG] wire -  >> "POST /login.php?do=login HTTP/1.1[\r][\n]"
2013/05/29 17:38:47:646 EEST [DEBUG] wire -  >> "Accept-Encoding: gzip,deflate[\r][\n]"
2013/05/29 17:38:47:646 EEST [DEBUG] wire -  >> "Content-Length: 61[\r][\n]"
2013/05/29 17:38:47:646 EEST [DEBUG] wire -  >> "Content-Type: application/x-www-form-urlencoded;
charset=UTF-8[\r][\n]"
2013/05/29 17:38:47:646 EEST [DEBUG] wire -  >> "Host: www.majaa.net[\r][\n]"
2013/05/29 17:38:47:647 EEST [DEBUG] wire -  >> "Connection: Keep-Alive[\r][\n]"
2013/05/29 17:38:47:647 EEST [DEBUG] wire -  >> "User-Agent: Apache-HttpClient/4.3-beta2-SNAPSHOT
(java 1.5)[\r][\n]"
2013/05/29 17:38:47:647 EEST [DEBUG] wire -  >> "[\r][\n]"
2013/05/29 17:38:47:647 EEST [DEBUG] headers - >> POST /login.php?do=login HTTP/1.1
2013/05/29 17:38:47:647 EEST [DEBUG] headers - >> Accept-Encoding: gzip,deflate
2013/05/29 17:38:47:647 EEST [DEBUG] headers - >> Content-Length: 61
2013/05/29 17:38:47:647 EEST [DEBUG] headers - >> Content-Type: application/x-www-form-urlencoded;
charset=UTF-8
2013/05/29 17:38:47:648 EEST [DEBUG] headers - >> Host: www.majaa.net
2013/05/29 17:38:47:648 EEST [DEBUG] headers - >> Connection: Keep-Alive
2013/05/29 17:38:47:648 EEST [DEBUG] headers - >> User-Agent: Apache-HttpClient/4.3-beta2-SNAPSHOT
(java 1.5)
2013/05/29 17:38:47:649 EEST [DEBUG] wire -  >> "vb_login_username=12testasd127&vb_login_password=12testasd127"
2013/05/29 17:38:47:809 EEST [DEBUG] wire -  << "HTTP/1.1 302 Found[\r][\n]"
2013/05/29 17:38:47:813 EEST [DEBUG] wire -  << "X-Powered-By: PHP/5.3.19[\r][\n]"
2013/05/29 17:38:47:813 EEST [DEBUG] wire -  << "Set-Cookie: bb_lastvisit=1369811510;
expires=Thu, 29-May-2014 07:11:50 GMT; path=/[\r][\n]"
2013/05/29 17:38:47:814 EEST [DEBUG] wire -  << "Set-Cookie: bb_lastactivity=0; expires=Thu,
29-May-2014 07:11:50 GMT; path=/[\r][\n]"
2013/05/29 17:38:47:814 EEST [DEBUG] wire -  << "Location: http://www.majaa.net/forum.php[\r][\n]"
2013/05/29 17:38:47:814 EEST [DEBUG] wire -  << "Content-type: text/html[\r][\n]"
2013/05/29 17:38:47:815 EEST [DEBUG] wire -  << "Content-Length: 0[\r][\n]"
2013/05/29 17:38:47:815 EEST [DEBUG] wire -  << "Date: Wed, 29 May 2013 07:11:50 GMT[\r][\n]"
2013/05/29 17:38:47:815 EEST [DEBUG] wire -  << "Server: lighttpd/1.4.31[\r][\n]"
2013/05/29 17:38:47:815 EEST [DEBUG] wire -  << "[\r][\n]"
2013/05/29 17:38:47:816 EEST [DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1
302 Found
2013/05/29 17:38:47:816 EEST [DEBUG] headers - << HTTP/1.1 302 Found
2013/05/29 17:38:47:817 EEST [DEBUG] headers - << X-Powered-By: PHP/5.3.19
2013/05/29 17:38:47:817 EEST [DEBUG] headers - << Set-Cookie: bb_lastvisit=1369811510;
expires=Thu, 29-May-2014 07:11:50 GMT; path=/
2013/05/29 17:38:47:818 EEST [DEBUG] headers - << Set-Cookie: bb_lastactivity=0; expires=Thu,
29-May-2014 07:11:50 GMT; path=/
2013/05/29 17:38:47:818 EEST [DEBUG] headers - << Location: http://www.majaa.net/forum.php
2013/05/29 17:38:47:819 EEST [DEBUG] headers - << Content-type: text/html
2013/05/29 17:38:47:819 EEST [DEBUG] headers - << Content-Length: 0
2013/05/29 17:38:47:820 EEST [DEBUG] headers - << Date: Wed, 29 May 2013 07:11:50 GMT
2013/05/29 17:38:47:820 EEST [DEBUG] headers - << Server: lighttpd/1.4.31
2013/05/29 17:38:47:834 EEST [DEBUG] ResponseProcessCookies - Cookie accepted: "[version:
0][name: bb_lastvisit][value: 1369811510][domain: www.majaa.net][path: /][expiry: Thu May
29 10:11:50 EEST 2014]". 
2013/05/29 17:38:47:834 EEST [DEBUG] ResponseProcessCookies - Cookie accepted: "[version:
0][name: bb_lastactivity][value: 0][domain: www.majaa.net][path: /][expiry: Thu May 29 10:11:50
EEST 2014]". 
2013/05/29 17:38:47:835 EEST [DEBUG] DefaultHttpClient - Connection can be kept alive indefinitely
302
{code}
                
> 'expect-continue' issue.
> ------------------------
>
>                 Key: HTTPCORE-342
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-342
>             Project: HttpComponents HttpCore
>          Issue Type: Task
>    Affects Versions: 4.3-beta2, 4.3-beta3
>            Reporter: Arūnas Bendoraitis
>
> I'm not really sure why it happens, but I manage to backtrack changes to a single commit.
> Not sure why it was reverted, but this revision now causes some problems with some hosts:
> Revision: 58760a12132862d1cc284585415a1440f2a1317b
> Author: Oleg Kalnichevski <olegk@apache.org>
> Date: 2012.11.21 17:58:58
> Message:
> Reverted changes introducing 'expect-continue' context attribute
> git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk@1412159 13f79535-47bb-0310-9956-ffa450edef68
> ----
> Modified: httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlers.java
> Modified: httpcore/src/examples/org/apache/http/examples/ElementalHttpGet.java
> Modified: httpcore/src/examples/org/apache/http/examples/ElementalHttpPost.java
> Modified: httpcore/src/main/java/org/apache/http/protocol/ExecutionContext.java
> Modified: httpcore/src/main/java/org/apache/http/protocol/HttpCoreContext.java
> Modified: httpcore/src/main/java/org/apache/http/protocol/RequestExpectContinue.java
> Modified: httpcore/src/test/java/org/apache/http/integration/TestSyncHttp.java
> Modified: httpcore/src/test/java/org/apache/http/protocol/TestStandardInterceptors.java
> For example:
>         HttpClient httpclient = new DecompressingHttpClient();
>         final List<NameValuePair> params = new ArrayList<NameValuePair>();
>         params.add(new BasicNameValuePair("vb_login_username", "test123"));
>         params.add(new BasicNameValuePair("vb_login_password", "test123"));
>         HttpPost httpPost = new HttpPost("http://www.majaa.net/login.php?do=login");
>         httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
>         HttpResponse response = httpclient.execute(httpPost);
>         System.out.println(response.getStatusLine().getStatusCode());
> This at the moment will output http status of 417 (which is not as excepted, since it
does not process request normally).
> If I revert that revision which mentioned above it works fine and outputs 302 (which
is what is expected).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message