0

force cleanup

Ok, last question of the night.

Can I force a response object to be cleaned up and then converted to an E4X object if it returns text/html as the mimetype? Basically I want

CODE
y.rest(url).header('Cookie', "stuff").get().response


to be the same as

CODE
y.query("SELECT * FROM html WHERE url=@url", {url : url})


except that it has the special cookie headers I want.

Implementation ideas :

CODE
y.rest(url).header('Cookie', "stuff").get().e4xresponse

CODE
y.rest(url).header('Cookie', "stuff").get().e4xresponse()

CODE
y.htmlToXml(y.rest(url).header('Cookie', "stuff").get().response)

by
3 Replies
  • QUOTE (Paul Tarjan @ Jun 23 2009, 09:17 PM) <{POST_SNAPBACK}>
    Ok, last question of the night.

    Can I force a response object to be cleaned up and then converted to an E4X object if it returns text/html as the mimetype? Basically I want

    CODE
    y.rest(url).header('Cookie', "stuff").get().response


    to be the same as

    CODE
    y.query("SELECT * FROM html WHERE url=@url", {url : url})


    except that it has the special cookie headers I want.

    Implementation ideas :

    CODE
    y.rest(url).header('Cookie', "stuff").get().e4xresponse

    CODE
    y.rest(url).header('Cookie', "stuff").get().e4xresponse()

    CODE
    y.htmlToXml(y.rest(url).header('Cookie', "stuff").get().response)



    Yes this is already implemented in the current release which is in production. You have to specify the accept header with "text/html" for the html clean up to happen

    The following line will do the trick
    CODE
     y.rest(url).accept("text/html").header("Cookie", "stuff").get().response


    -- Nagesh
    0
  • QUOTE (Nagesh Susarla @ Jun 24 2009, 10:03 AM) <{POST_SNAPBACK}>
    Yes this is already implemented in the current release which is in production. You have to specify the accept header with "text/html" for the html clean up to happen

    The following line will do the trick
    CODE
     y.rest(url).accept("text/html").header("Cookie", "stuff").get().response


    -- Nagesh


    wonderful. That's a little non-intuitive that by setting the accept header I end up cleaning up the data, but in hindsight it makes sense. Maybe a little callout in the manual?
    0
  • QUOTE (Paul Tarjan @ Jun 24 2009, 10:38 AM) <{POST_SNAPBACK}>
    wonderful. That's a little non-intuitive that by setting the accept header I end up cleaning up the data, but in hindsight it makes sense. Maybe a little callout in the manual?


    Earlier during our dev phase, we made cleanup the default but realized that devs would want raw output in all cases unless they specifically asked for this behavior. We encoded that specific knowledge in the accept header. I agree we could have done it differently but we wanted to stay away from adding another method to the "y" global object.

    Totally agree about the documentation and this is being worked on as we speak.
    -- Nagesh
    0

Recent Posts

in YQL