Commit Graph

44 Commits

Author SHA1 Message Date
Aleric Inglewood
024c62aed4 Fix the "map/set iterators incompatible" bug.
cookies is only valid when AIHTTPReceivedHeaders::getValues return true.
2013-01-12 04:24:21 +01:00
Aleric Inglewood
f9738cb611 Add getName() to every non-base class Responder object. 2013-01-11 04:15:55 +01:00
Aleric Inglewood
b22832ba54 Fix cookie handling.
Cookies are now collected during redirects, one the last cookie
of a given name is kept. Cookies are then set by looking for
the right cookie name (instead of what viewer 3 does: just
use the last cookie that was set).

This fixes the merchant outbox.
2012-12-24 19:58:54 +01:00
Aleric Inglewood
fac3fc67b6 Add filtering for curl debug output.
Add CURLTR debug channel for libcurl API calls,
and use CURLIO only for libcurl debug output.
Note: need to set gDebugCurlTerse to true for
filtering to take effect, then pass 'debug_on'
to the LLHttpClient methods that require debugging.
2012-12-24 02:54:36 +01:00
Aleric Inglewood
8095d6c48c Large snapshot update (part 3) 2012-12-22 19:07:08 +01:00
Aleric Inglewood
c097d650dc Don't upload partial files 2012-11-14 19:26:16 +01:00
Aleric Inglewood
b7af32bee3 Use std::istream::read instead of readsome
According to the docs
(http://www.cplusplus.com/reference/iostream/istream/readsome/)
readsome would also set state flag eofbit, but apparently I'm
misinterpreting it.  Anyway, using read() and then gcount()
to get the number of bytes does work.
2012-11-14 18:37:44 +01:00
Aleric Inglewood
e307df79a1 Ignore the body in case of internal errors 2012-11-14 04:00:26 +01:00
Aleric Inglewood
6f8ea87c46 Add ResponderHeadersOnly.
ResponderHeadersOnly is a base class for responders that use
HTTPClient::head or HTTPClient::getHeaderOnly. It already
has a needsHeaders() that return true and only allows for
completedHeaders to be overridden.

I removed the CURLOPT_HEADER option for these cases, because
that only causes the headers to be send to the writeCallback
as if they are part of the body, in addition to the headerCallback;
That gave raise to some confusion for the existing code (ie,
unexpected errors when trying to decode the body as LLSD and
duplicated 'low speed' information for the Timeout policy code.
2012-11-13 21:46:35 +01:00
Aleric Inglewood
04e7dc1270 Collect and print stats about HTTP status code 2012-11-10 02:19:20 +01:00
Aleric Inglewood
cb52e82a60 Moved and extended AICurlInterface::Stats
Moved AICurlPrivate::Stats to AICurlInterface::Stats and added several
counters to keep track of the number of existing instances of
respectively AICurlEasyRequest, AICurlEasyRequestStateMachine,
BufferedCurlEasyRequest, ResponderBase and
ThreadSafeBufferedCurlEasyRequest.
2012-11-07 02:15:23 +01:00
Aleric Inglewood
a495a6bfbc Short circuit llsd debug check. 2012-11-05 01:04:02 +01:00
Aleric Inglewood
c0ac428179 Code cleanup
* Moved Responder stuff to LLHTTPClient.
* Renamed LLHTTPClient::Responder to LLHTTPClient::ResponderWithResult.
* Deleted LLHTTPClientAdapter and LLHTTPClientInterface.
* Renamed AICurlInterface::TransferInfo to AITransferInfo and moved it
  to llhttpclient.h
* Removed 'CURLcode code' argument from completed_headers.
2012-10-31 23:11:42 +01:00
Aleric Inglewood
0b265320a9 Code clean up.
* Removed LLCurlRequest and replaced it's last usage with LLHTTPClient API calls.
* Deleted dead code.
* Renamed all the get4/post4/put4/getByteRange4 etc, back to their
  original name without the '4'.
2012-10-31 05:01:24 +01:00
Aleric Inglewood
9996cf6157 Bug fix 2012-10-30 21:17:25 +01:00
Aleric Inglewood
65e012c540 More curl fixes and changes.
* Moved LegacyPolledResponder::mCode to ResponderBase::mCode.
* Added a parameter to ResponderBase::finished (and pubError*) to set mCode.
* Renamed ResponderBase::decode_body to decode_llsd_body and added ResponderBase::decode_raw_body.
* Use LegacyPolledResponder::finished instead of LegacyPolledResponder::completed_headers
  to set remaining cached values.
* Fixed assertion in case of -DCWDEBUG and upload finish detection failure in case of HEAD
  method (mDebugIsGetMethod -> mDebugIsHeadOrGetMethod).
* Add XmlTreeInjector : support for LLXmlTree.
* Split BlockingResponder into BlockingLLSDResponder and BlockingRawResponder.
* Final blocking responders are now: BlockingLLSDPostResponder, BlockingLLSDGetResponder
  and BlockingRawGetResponder.
* Added LLHTTPClient::blockingGetRaw
* Got rid of hipporestrequest.* -- and fixed hippogridmanager.cpp to use
  LLHTTPClient::blockingGetRaw instead, and fixed llviewermessage.cpp to use
  AICurlInterface::ResponderWithCompleted and decode_raw_body instead of
  HippoRestHandlerRaw and LLHTTPClient::get4 instead of HippoRestRequest::get5.
2012-10-28 17:38:25 +01:00
Aleric Inglewood
2a88f7d7c4 ResponderAdapter stuff
Renamed AICurlInterface::Responder to AICurlInterface::ResponderBase,
but without the virtual 'event' methods.
Derived from that: Responder and ReponderWithCompleted, where the
first defines result = 0, ErrorWithContent and error, and the latter
completedRaw and completed.
Added HttpClient::IgnoreBody, derived from Responder and implementing
'result' doing nothing; HttpClient::Ignore is now derived from
IgnoreBody and defines the still pure virtual getHTTPTimeoutPolicy.

Added ResponderBase::decode_body, which is now the sole place
where the code makes the decision wether some response data might be
LLSD or not based on the http status result. Before it just tried
to decode everything as LLSD, which seems a bit nonsense.

ResponderWithCompleted::completed no longer does anything, since
classes derived from ResponderWithCompleted are expected to override it,
or never call it by overriding completedRaw.

Entry point is now ResponderBase::finished = 0, instead of
completedRaw, where ResponderWithCompleted implements finished by
called completedRaw, but Responder doesn't: that directly calls
result/errorWithContent/error. Or, for the hack ResponderAdapter,
the entry points are pubResult/pubErrorWithContent.
Those are now the ONLY public methods, so more confusion.
mFinished is now set in all cases.

As a result of all that, it is no longer possible to accidently
pass a responder to ResponderAdapter that would break because it
expects completed() and completedRaw() to be called.

Added LLBufferArray::writeChannelTo.

Fixed bug for BlockingResponder::body (returned reference to temporary).

LLSDMessage::ResponderAdapter now allows a "timeoutpolicy" name
to be passed (not doing so results in the default timings), so
that the timeout policy of the used responder is retained.

Fixed llfasttimerview.cpp to test LLSDSerialize::fromXML() to return
a positive value instead of non-zero, because it may return -1 when the
parsing fails (three places).

Removed LLHTTPClient::Responder as base class from
LLFloaterRegionDebugConsole completely: it isn't a responder!

Several other responder classes were simplified a bit in order to
compile again with the above changes.
2012-10-26 04:13:29 +02:00
Aleric Inglewood
243db9a3a8 Moved mFinished/is_finished() from LegacyPolledResponder to Responder.
Slightly more robust, adds one boolean to all responders, 99%
of which don't need that though, and an extra call redirection,
but well... We might need it this way when I add the possibility
to abort a transfer.
2012-10-22 22:52:18 +02:00
Aleric Inglewood
768f1b5710 Fixes blocking_request. Adds LegacyPolledResponder and BlockingResponder.
XMLRPCResponder also uses the new LegacyPolledResponder now.
Renamed http_result() -> http_status().
2012-10-22 20:19:44 +02:00
Aleric Inglewood
7f50b2ba7b Add XMLRPC support to LLHTTPClient and that instead of LLXMLRPCTransaction 2012-10-22 01:59:17 +02:00
Aleric Inglewood
f8273e977e Make NoVerifySSLCert work for all LLURLRequest
Moved CURLOPT_ENCODING from CurlEasyRequest::setPost_raw, and
CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST from
CurlResponderBuffer::prepRequest, to LLURLRequest::configure,
enabling the debug setting NoVerifySSLCert for the latter
two to work as follows: old behavior if "NoVerifySSLCert"
is not set, and check neither if it is set. However, if
the (new) bool mIsAuth is set the behavior of LLXMLRPCTransaction::Impl::init
is used. This is so in a next commit we can replace
LLXMLRPCTransaction with LLURLRequest: LLXMLRPCTransaction::Impl::init
will be removed. For the same reason, when the new boolean
mNoCompression is set then CURLOPT_ENCODING is set to "identity",
otherwise the old behavior (of clearing it) is used.
2012-10-20 23:28:33 +02:00
Aleric Inglewood
3f1fb9a66e Add improved timeout handling for HTTP transactions.
Introduces AIHTTPTimeoutPolicy objects which do not just
specify a single "timeout" in seconds, but a plethora of
timings related to the life cycle of the average HTTP
transaction.

This knowledge is that moved to the Responder being
used instead of floating constants hardcoded in the
callers of http requests. This assumes that the same
timeout policy is wanted for each transaction that
uses the same Responder, which can be enforced is needed.

I added a AIHTTPTimeoutPolicy for EVERY responder,
only to make it easier later to tune timeout values
and/or to get feedback about which responder runs
into HTTP errors in debug output (especially time outs),
so that they can be tuned later. If we already understood
exactly what we were doing then most responders could
have been left alone and just return the default timeout
policy: by far most timeout policies are just a copy
of the default policy, currently.

This commit is not finished... It's a work in progress
(viewer runs fine with it though).
2012-10-05 15:53:29 +02:00
Aleric Inglewood
1254a7bbe2 Merge remote-tracking branch 'github/master' into curlthreading3
Conflicts:
	indra/aistatemachine/aistatemachine.cpp
2012-09-22 01:25:54 +02:00
Aleric Inglewood
81bc6b49f8 Debug code bug fix; removal of CurlEasyHandle::getErrorString()
CurlEasyHandle::mErrorBuffer (CURLOPT_ERRORBUFFER) can NOT be
used to retrieve information about an error returned by
curl_multi_info_read in CURLMsg::data::result. This buffer is
only initialized when a curl_easy_* call returns an error,
and those errors are already printed automagically.

Initialize the buffer with an empty string upon invokation
of an curl_easy_* call, so we are sure the error belongs to
the last call.
2012-09-21 01:28:26 +02:00
Aleric Inglewood
2d12a82a54 Always flush LLBufferStream objects. 2012-09-20 04:49:43 +02:00
Aleric Inglewood
1d5a63c180 Fixed showing TOS floater.
This creates a separate events interface structure
for CurlResponderBuffer (AICurlResponderBufferEvents)
for dealing with received HTTP headers.

The headers are passed to the Responder, but only
if the class derived from Responder implements
completedHeaders (otherwise it makes little sense
to even decode the headers).

Basically this is a reimplementation of the functionality
of the old LLHTTPClientURLAdaptor class.
2012-09-18 23:59:09 +02:00
Aleric Inglewood
83b13f6a3f WIP: make everything use AICurlEasyRequestStateMachine 2012-08-20 21:18:19 +02:00
Aleric Inglewood
536cb6febd Merge branch 'curlthreading2' into curlthreading3
Conflicts:
	indra/CMakeLists.txt
	indra/llcommon/llstring.h
	indra/llmessage/CMakeLists.txt
	indra/llmessage/llhttpclient.cpp
	indra/llmessage/llhttpclient.h
	indra/llmessage/llurlrequest.cpp
	indra/llmessage/llurlrequest.h
	indra/newview/hipporestrequest.cpp
	indra/newview/llappviewer.cpp
2012-08-15 00:51:40 +02:00
Aleric Inglewood
19293601b3 Manual pick of stuff from 'shycurl' (68ad5411) that seemed to make sense. 2012-08-14 02:38:06 +02:00
Siana Gearz
36ff4dcd11 Don't feed empty, non-working callback to CURL
Cherry-Pick of 96a4e16a

Conflicts:
	indra/llmessage/llurlrequest.cpp
	indra/llmessage/llurlrequest.h
	indra/newview/hipporestrequest.cpp

Clear reasons for conflicts, resolved.
2012-08-13 23:33:49 +02:00
Aleric Inglewood
35a53ef1d7 Bug fix (needed for libcwd with memory allocation debugging) 2012-08-13 21:59:57 +02:00
Aleric Inglewood
304fa05094 Suppress "Expect:" header for POST and PUT. No longer use CURLOPT_COPYPOSTFIELDS.
For POST and PUT, libcurl adds by default a "Expect: 100-continue"
header and wait for the server to reply with a 100 response.
However, since the server never does that (LL comment in the
code "I'm not sure what it means") it's up to libcurl to continue
anyway after a while and that part is apparently bugged, causing
people not to be able to login sometimes. But suppressing the
header, libcurl doesn't wait for it and we worked around this bug.

The commit introduces a much improved CurlEasyRequest::setPost
method that enforces the above for POST, but that also no longer
uses CURLOPT_COPYPOSTFIELDS (but CURLOPT_POSTFIELDS), no longer
making a copy of the body of what we are going to send to the server.
Instead it uses a new object, derived from AIPostField, to keep track
of this data and to dispose of it once the transaction is complete
(and no sooner).

Copied from llcorehttp, we now also always set a "Connection:
keep-alive" and "Keep-alive: 300" header for POST.
This was already done for texture downloads (HttpOpRequest),
but now we do it always :p. Might need to be changed in the
future, but currently those headers are ignored by the server
anyway.
2012-08-12 16:34:20 +02:00
Aleric Inglewood
b2c5a84964 Replace CURLOPT_POSTFIELDSIZE_LARGE with CURLOPT_POSTFIELDSIZE
Also adds a more robust interface for setopt that does
type checking based on the options used. This fixes one
bug where a F32 was passed and interpreted as long.
In many cases a U32 or S32 was passed as long, which
would fail (only) on a 64bit non-windows big endian machine.
2012-08-10 04:18:04 +02:00
Aleric Inglewood
95083e846b WIP 2012-08-06 23:19:09 +02:00
Aleric Inglewood
caef97ad36 Print all libcurl calls if -DDEBUG_CURLIO. Don't create static lib for cwdebug.
Basically, cmake doesn't support linking static libs into a shared lib.
The correct way is to just specify source files in subdirectories
directly as source files of the shared library. This patch changes that.

Also, after this commit, when DEBUG_CURLIO is defined, every call to
libcurl is printed to llinfos (or to dc::curl when using libcwd).
2012-08-05 18:51:21 +02:00
Aleric Inglewood
5fb4badb7c WIP 2012-08-02 22:34:23 +02:00
Aleric Inglewood
29908533cd More work in progress 2012-07-31 22:23:52 +02:00
Aleric Inglewood
af4ac8fb5f WIP: work on rewriting LLURLRequest 2012-07-29 01:30:11 +02:00
Aleric Inglewood
69ca6cd5b2 WIP: Make curl thread code robust and flexible.
Conflicts:

	indra/llmessage/llcurl.cpp
	indra/llmessage/llcurl.h
	indra/newview/app_settings/settings.xml
	indra/newview/llappviewer.cpp
	indra/newview/llmeshrepository.cpp

Resolved:

	indra/llmessage/llcurl.cpp:

	  Basically removed (not used anyway)

	indra/llmessage/llcurl.h:

	  Basically removed (just includes aiculr.h now)

	indra/newview/app_settings/settings.xml:

	  CurlUseMultipleThreads was remvoved.
	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are still in there, but unused at the moment.

	indra/newview/llappviewer.cpp:

	  CurlMaximumNumberOfHandles and CurlRequestTimeOut
	  are unused at the moment.

	indra/newview/llmeshrepository.cpp:

	  Lock mSignal always (is unlocked inside wait()).
	  Use mSignal lock to see if we are waiting; remove mWaiting.
	  Return false from the MeshFetch functions iff we have to retry
	  a HTTP fetch. Catch the error exception thrown by getByteRange
	  instead of using it's return value (always returns true
	  anyway).
2012-06-28 01:30:46 +02:00
Siana Gearz
8b6f462d13 Wholesale update of llmessage to V3.2
Note that this removes message logger for now.
2012-03-06 07:31:15 +01:00
Siana Gearz
179f4ddabb The Octopus Feature
___
                     .-'   `'.
                    /         \
                    |         ;
                    |         |           ___.--,
           _.._     |0) ~ (0) |    _.---'`__.-( (_.
    __.--'`_.. '.__.\    '--. \_.-' ,.--'`     `""`
   ( ,.--'`   ',__ /./;   ;, '.__.'`    __
   _`) )  .---.__.' / |   |\   \__..--""  """--.,_
  `---' .'.''-._.-'`_./  /\ '.  \ _.-~~~````~~~-._`-.__.'
        | |  .' _.-' |  |  \  \  '.               `~---`
         \ \/ .'     \  \   '. '-._)
          \/ /        \  \    `=.__`~-.
     jgs  / /\         `) )    / / `"".`\
    , _.-'.'\ \        / /    ( (     / /
     `--~`   ) )    .-'.'      '.'.  | (
            (/`    ( (`          ) )  '-;
             `      '-;         (-'
2011-03-24 23:54:23 +01:00
Shyotl
f9937d7f8a V2 llmessage merge, incl. llcommon requisites.
Excluded llareslistener, as that appears to only be present for unit-testing
Excluded new SSL methods because, well, they don't work right reliably in v2 for me
2011-02-25 19:30:59 -06:00
Beeks
59d7c33954 Collection of theoretical improvements for ATI cards, as well as a couple memory leaks. Thanks to Shyotl for bringing them up and offering solutions.
Signed-off-by: Beeks <HgDelirium@gmail.com>
2010-09-16 16:00:47 -04:00
Hazim Gazov
7a86d01598 Imported existing code 2010-04-02 02:48:44 -03:00