diff options
author | Kevin Cozens | 2013-03-27 11:52:10 -0400 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-03-29 23:35:12 +0000 |
commit | 8b1ca7b35e8e5bb65666fb566c0e797aaa999a4e (patch) | |
tree | 466198acc081c32b726ffdc70f7bac800b5da86a /OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |
parent | Change 0.7.5 flavour to post-fixes (diff) | |
download | opensim-SC_OLD-8b1ca7b35e8e5bb65666fb566c0e797aaa999a4e.zip opensim-SC_OLD-8b1ca7b35e8e5bb65666fb566c0e797aaa999a4e.tar.gz opensim-SC_OLD-8b1ca7b35e8e5bb65666fb566c0e797aaa999a4e.tar.bz2 opensim-SC_OLD-8b1ca7b35e8e5bb65666fb566c0e797aaa999a4e.tar.xz |
Added missing functionality (mainly custom headers) to llHTTPRequest.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a676971..c2e37c4 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -187,6 +187,45 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
187 | case (int)HttpRequestConstants.HTTP_VERIFY_CERT: | 187 | case (int)HttpRequestConstants.HTTP_VERIFY_CERT: |
188 | htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0); | 188 | htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0); |
189 | break; | 189 | break; |
190 | |||
191 | case (int)HttpRequestConstants.HTTP_VERBOSE_THROTTLE: | ||
192 | |||
193 | // TODO implement me | ||
194 | break; | ||
195 | |||
196 | case (int)HttpRequestConstants.HTTP_CUSTOM_HEADER: | ||
197 | //Parameters are in pairs and custom header takes | ||
198 | //arguments in pairs so adjust for header marker. | ||
199 | ++i; | ||
200 | |||
201 | //Maximum of 8 headers are allowed based on the | ||
202 | //Second Life documentation for llHTTPRequest. | ||
203 | for (int count = 1; count <= 8; ++count) | ||
204 | { | ||
205 | //Not enough parameters remaining for a header? | ||
206 | if (parms.Length - i < 2) | ||
207 | break; | ||
208 | |||
209 | //Have we reached the end of the list of headers? | ||
210 | //End is marked by a string with a single digit. | ||
211 | //We already know we have at least one parameter | ||
212 | //so it is safe to do this check at top of loop. | ||
213 | if (Char.IsDigit(parms[i][0])) | ||
214 | break; | ||
215 | |||
216 | if (htc.HttpCustomHeaders == null) | ||
217 | htc.HttpCustomHeaders = new List<string>(); | ||
218 | |||
219 | htc.HttpCustomHeaders.Add(parms[i]); | ||
220 | htc.HttpCustomHeaders.Add(parms[i+1]); | ||
221 | |||
222 | i += 2; | ||
223 | } | ||
224 | break; | ||
225 | |||
226 | case (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE: | ||
227 | htc.HttpPragmaNoCache = (int.Parse(parms[i + 1]) != 0); | ||
228 | break; | ||
190 | } | 229 | } |
191 | } | 230 | } |
192 | } | 231 | } |
@@ -328,9 +367,12 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
328 | // public const int HTTP_METHOD = 0; | 367 | // public const int HTTP_METHOD = 0; |
329 | // public const int HTTP_MIMETYPE = 1; | 368 | // public const int HTTP_MIMETYPE = 1; |
330 | // public const int HTTP_VERIFY_CERT = 3; | 369 | // public const int HTTP_VERIFY_CERT = 3; |
370 | // public const int HTTP_VERBOSE_THROTTLE = 4; | ||
371 | // public const int HTTP_CUSTOM_HEADER = 5; | ||
372 | // public const int HTTP_PRAGMA_NO_CACHE = 6; | ||
331 | private bool _finished; | 373 | private bool _finished; |
332 | public bool Finished | 374 | public bool Finished |
333 | { | 375 | { |
334 | get { return _finished; } | 376 | get { return _finished; } |
335 | } | 377 | } |
336 | // public int HttpBodyMaxLen = 2048; // not implemented | 378 | // public int HttpBodyMaxLen = 2048; // not implemented |
@@ -340,11 +382,14 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
340 | public string HttpMIMEType = "text/plain;charset=utf-8"; | 382 | public string HttpMIMEType = "text/plain;charset=utf-8"; |
341 | public int HttpTimeout; | 383 | public int HttpTimeout; |
342 | public bool HttpVerifyCert = true; | 384 | public bool HttpVerifyCert = true; |
385 | //public bool HttpVerboseThrottle = true; // not implemented | ||
386 | public List<string> HttpCustomHeaders = null; | ||
387 | public bool HttpPragmaNoCache = true; | ||
343 | private Thread httpThread; | 388 | private Thread httpThread; |
344 | 389 | ||
345 | // Request info | 390 | // Request info |
346 | private UUID _itemID; | 391 | private UUID _itemID; |
347 | public UUID ItemID | 392 | public UUID ItemID |
348 | { | 393 | { |
349 | get { return _itemID; } | 394 | get { return _itemID; } |
350 | set { _itemID = value; } | 395 | set { _itemID = value; } |
@@ -360,7 +405,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
360 | public string proxyexcepts; | 405 | public string proxyexcepts; |
361 | public string OutboundBody; | 406 | public string OutboundBody; |
362 | private UUID _reqID; | 407 | private UUID _reqID; |
363 | public UUID ReqID | 408 | public UUID ReqID |
364 | { | 409 | { |
365 | get { return _reqID; } | 410 | get { return _reqID; } |
366 | set { _reqID = value; } | 411 | set { _reqID = value; } |
@@ -401,7 +446,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
401 | Request.Method = HttpMethod; | 446 | Request.Method = HttpMethod; |
402 | Request.ContentType = HttpMIMEType; | 447 | Request.ContentType = HttpMIMEType; |
403 | 448 | ||
404 | if(!HttpVerifyCert) | 449 | if (!HttpVerifyCert) |
405 | { | 450 | { |
406 | // We could hijack Connection Group Name to identify | 451 | // We could hijack Connection Group Name to identify |
407 | // a desired security exception. But at the moment we'll use a dummy header instead. | 452 | // a desired security exception. But at the moment we'll use a dummy header instead. |
@@ -412,14 +457,24 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
412 | // { | 457 | // { |
413 | // Request.ConnectionGroupName="Verify"; | 458 | // Request.ConnectionGroupName="Verify"; |
414 | // } | 459 | // } |
415 | if (proxyurl != null && proxyurl.Length > 0) | 460 | if (!HttpPragmaNoCache) |
461 | { | ||
462 | Request.Headers.Add("Pragma", "no-cache"); | ||
463 | } | ||
464 | if (HttpCustomHeaders != null) | ||
416 | { | 465 | { |
417 | if (proxyexcepts != null && proxyexcepts.Length > 0) | 466 | for (int i = 0; i < HttpCustomHeaders.Count; i += 2) |
467 | Request.Headers.Add(HttpCustomHeaders[i], | ||
468 | HttpCustomHeaders[i+1]); | ||
469 | } | ||
470 | if (proxyurl != null && proxyurl.Length > 0) | ||
471 | { | ||
472 | if (proxyexcepts != null && proxyexcepts.Length > 0) | ||
418 | { | 473 | { |
419 | string[] elist = proxyexcepts.Split(';'); | 474 | string[] elist = proxyexcepts.Split(';'); |
420 | Request.Proxy = new WebProxy(proxyurl, true, elist); | 475 | Request.Proxy = new WebProxy(proxyurl, true, elist); |
421 | } | 476 | } |
422 | else | 477 | else |
423 | { | 478 | { |
424 | Request.Proxy = new WebProxy(proxyurl, true); | 479 | Request.Proxy = new WebProxy(proxyurl, true); |
425 | } | 480 | } |
@@ -432,7 +487,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
432 | Request.Headers[entry.Key] = entry.Value; | 487 | Request.Headers[entry.Key] = entry.Value; |
433 | 488 | ||
434 | // Encode outbound data | 489 | // Encode outbound data |
435 | if (OutboundBody.Length > 0) | 490 | if (OutboundBody.Length > 0) |
436 | { | 491 | { |
437 | byte[] data = Util.UTF8.GetBytes(OutboundBody); | 492 | byte[] data = Util.UTF8.GetBytes(OutboundBody); |
438 | 493 | ||