mobilizingcs / MobilizePrime

Simple wrapper functions for high school curriculum
http://www.exploringcs.org/curriculum
5 stars 2 forks source link

Problems accessing https version oh ohmage with XML package #41

Closed jimmylovestea closed 9 years ago

jimmylovestea commented 9 years ago

There seems to be an issue using the XML package in R to read .xml files on the https version of ohmage. The problem seems to be an inadequacy in R which is causing some of the code we'd like to use in the labs to fail.

Examples that don't work:

xmlParse("https://web.ohmage.org/mobilize/resources/ids/data/mountains.xml") # https
xmlParse("http://web.ohmage.org/mobilize/resources/ids/data/mountains.xml") # http

Example that does work:

xmlParse("http://www.stat.ucla.edu/~james.molyneux/mountains.xml")

@stevenolen Is it possible to open the port to the http://web.ohmage.org/mobilize/resources/ids/data/mountains.xml site?

stevenolen commented 9 years ago

I've disabled all non-https interactions with that webserver because unless absolutely required, HTTPS everywhere is best practice.

Is there any reason why the proposed solution in the post by @jeroenooms isn't acceptable?

jeroen commented 9 years ago

You an either use:

library(curl)
xmltext <- readLines(curl("https://web.ohmage.org/mobilize/resources/ids/data/mountains.xml"), warn = FALSE)
mountains <- xmlParse(xmltext)

Or:

library(httr)
req <- GET("https://web.ohmage.org/mobilize/resources/ids/data/mountains.xml")
mountains <- content(req)
stevenolen commented 9 years ago

Discussed with @hongsudt, it's out of the scope to teach kids this extra step needed for https and R, web.ohmage.org will now serve non-https requests to urls/files under http://web.ohmage.org/mobilize/resources/ids/data/

jeroen commented 9 years ago

:)

jeroen commented 9 years ago

Cause It's important we teach them something that won't work in practice :P