cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: NTLM Small file (< 2000 bytes) upload fails

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 9 Jun 2013 23:56:54 +0200 (CEST)

On Fri, 31 May 2013, vaugham hong wrote:

Hi,

Thanks for your report. I think we need to understand why you see this problem
and yet our existing NTLM test cases seem to continue to run as good as they
have been for a very long time!

Could be the lack of a rewind function set by your program?

> There seems to be some code that is specific to NTLM and uploads of < 2000
> bytes (located at http.c line~386).
>
> ////////////////////////////////////////////////////////////////////////////////////////////////////
> if((*(expectsend - bytessent) < 2000)* || (conn->ntlm.state !=
> NTLMSTATE_NONE) || (conn->proxyntlm.state != NTLMSTATE_NONE)) {
> /* The NTLM-negotiation has started *OR* there is just a little (<2K)
> data left to send, keep on sending. */

I take it both conn->ntlm.state and conn->proxyntlm.state are then
NTLMSTATE_NONE at that point?

> *A Solution*
> 2000 seemed like an odd number. Through my naivety, I decided to remove the
> restriction on < 2000 bytes and see what happens. And lo and behold, small
> file uploads work.

2000 is just an arbitrary number small number. But If you read the comment
again you'll see that it attempts to not disconnect at all when NTLM is used!
It is because NTLM is connection-based so closing a connection means
restarting the "handshake".

> *Questions*
> + If we are below 2000 bytes and working with NTLM, we set rewindaftersend
> = true. What is the purpose of this? The change above means rewindaftersend
> does not get set, and our NTLM authentication continues, eventually
> authenticates and uploads our file.

It means that we send the data more than once, and in order to send the same
data again libcurl tells the application to "rewind".

> + Why 2000 bytes?

Because sending 2000 bytes "in vain" (and resending them later) could be
faster than tearing down and setting up a connection.

> + I'd like to test this against some test cases - Is the test framework
> functioning for libcurl 7.30.0?

Yes

> I've tried running it, but I get various lexical errors in Makefile.am (eg.
> line 69 perhcheck -> perlcheck).

What did you try?

> + Does anyone have any insights on alternative solutions to upload small
> files (<2000 bytes) using NTLM authentication?

You need to give us more details. Like a full example with the problem, or
possibly to start with some VERBOSE logs that shows what happens/is logged in
the failing case.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-06-09