Re: [R] RCurl: authentication when posting forms

2008-08-29 Thread EBo

I do not know if this is related, but for some functions to work properly
cookies, java, and/or javaqscript need to be enabled.  Some of the current
pages do not check for requirements and warn, they just don't work properly.

Just a thought of something else to try...

  EBo --


Duncan Temple Lang [EMAIL PROTECTED] said:

 
 --OXfL5xGRrasGEqWY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Valerie Obenchain wrote:
  Duncan,
 =20
  Thank you for the examples.  I had tried all of these different options=
 =20
  for authentication but had no luck. I was getting a 100 continue and=20
  then a 401 unauthorized response.  This morning the owners of the=20
  server I was trying to access discovered a bug with their api when using=
 =20
  basic authorization. Evidently the code on their side was explicitly=20
  checking that the request method was GET, hence why all of my POST=20
  attempts were failing. They are in the process of fixing that code and=20
  my guess is that when I am able to try again the RCurl post functions=20
  will work just fine.
 
 Thanks for the update.  Good to know that there isn't a problem
 with the libcurl/RCurl code.
 
 =20
  I did have one other RCurl question I'd like to ask you about the=20
  parseHTTPHeader function.
 =20
  The parser appears to parse on spaces, so when the error message is more=
 =20
  than one word (eg, not found), the message returned is not. I have=20
  modified the parseHTTPHeader function so that it works for me. I may not=
 =20
  have done this in the most efficient way but at least you can see what I=
 =20
  was trying to do.
 
 
 Yes, this is a problem. Thanks for bringing it to my attention.
 I did get your mail directly to me from about 2 weeks ago=20
 and I replied. Perhaps my reply got eaten by your filters.
 In it, I said that it was a bug, and that it would be
 very useful if you could send me an RCurl command
 that illustrated the error so that I could add it to the RCurl
 tests.
 =20
 
 The only modification that can make your patch slightly
 better is that the words in the statusMessage are essentially
 all the words in the status variable, less the first two
 (the status number and the protocol name). So
 
  header[[statusMessage]] - paste(els[-c(1,2)], collapse =3D  )
 
 is more convenient than
 
   hstring - NULL
   for(i in 3:length(els)) hstring - paste(hstring, ,els[i],sep=3D)
   hstring - substr(hstring,2,nchar(hstring))
   header[[statusMessage]] - hstring
 
 
 If you do have a URL that I can use to test the error handling code, I'd ap=
 preciate
 if you could send it to me. =20
 
 
  D.
 
 =20
  Below I have pasted my modification for the parseHTTPHeader function=20
  which I am calling parseHeader. Please let me know if you think this is=
 =20
  a bug or if I am just using the function incorrectly.
 =20
  Thank you for the help.
  Valerie
 =20
  #---
  #Sample code:
  reader - basicTextGatherer()
  header - basicTextGatherer()
  handle - getCurlHandle()
  myopts - curlOptions(  netrc=3D1, httpheader=3Dc(Authorization=3Dmypwd,=
 =20
  Accept=3Dtest/xml,
Accept=3Dmultipart/*,=20
  'Content-Type'=3Dtext/xml; charset=3Dutf-8),
postfields=3Dbody,=20
  writefunction=3Dreader$update, headerfunction=3Dheader$update,
ssl.verifyhost=3DFALSE,=20
  ssl.verifypeer=3DFALSE, followlocation=3DTRUE)} else
 =20
  curlPerform(url=3DmyUrl, .opts=3Dmyopts, curl=3Dhandle)
  h - parseHeader(header$value())
  status - h$status
  message - h$statusMessage
  #
 =20
  #Modified parse function:
  parseHeader - function (lines)
  {
if (length(lines)  1)
return(NULL)
if (length(lines) =3D=3D 1)
lines =3D strsplit(lines, \r\n)[[1]]
status =3D lines[1]
lines =3D lines[-c(1, length(lines))]
lines =3D gsub(\r\n, , lines)
if (FALSE) {
header =3D lines[-1]
header - read.dcf(textConnection(header))
}
else {
els - sapply(lines, function(x) strsplit(x, :[ ]*))
header - lapply(els, function(x) x[2])
names(header) - sapply(els, function(x) x[1])
}
els - strsplit(status,  )[[1]]
header[[status]] - as.integer(els[2])
  # new code below
hstring - NULL
for(i in 3:length(els)) hstring - paste(hstring, ,els[i],sep=3D)
hstring - substr(hstring,2,nchar(hstring))
header[[statusMessage]] - hstring
header
  }
 =20
 =20
 =20
 =20
 =20
 =20
 =20
 =20
 =20
 =20
 =20
 =20
  Duncan Temple Lang wrote:
  
  
  Hi Valerie
  
  Valerie Obenchain wrote:
  Hi,
  
  Has anyone successfully used RCurl for posting data to a=20
  password-protected site?=20
  
  Yes. I just set up a sample form to test with and the following
  all work
  
  
  # Perl script (and HTML form for testing

[R] accessing sd and var functions in embedded app

2008-08-27 Thread EBo
I am able to call R functions like min, mean, and mad from from a C/C++
embedded application, but when I try to get the standard deviation or variance
(sd, var) R segfaults.  Can someone suggest how to resolve this?

Thanks and best regards,

  EBo --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] embedded examples

2008-08-26 Thread EBo

I am working on embedding R into some visualization research programs.  Can
any point me to a collection of embedded and standalone R/C/C++ examples?  The
documentation is to terse for me to figure out how to develop this and I am
looking for some simple examples to study.

  Thanks and best regards,

  EBo --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.