Response from Eve xml to http?

245 views Asked by At

I am having a hard time to configure eve. The http client expect the response to be in this format where it starts with HTTP/1.1 and the response codes and then the headers. What is get back is something like an xml format. What I get back shown below:

This is what I expect:

0   0  48545450 2F312E31 20323030 204F4B0D  HTTP/1.1  200 OK.
16  10  0A436F6E 74656E74 2D547970 653A2074  .CONTENT -TYPE: T
32  20  6578742F 706C6169 6E0D0A43 6F6E7465  EXT/PLAI N..CONTE
48  30  6E742D4C 656E6774 683A2030 30303035  NT-LENGT H: 00005
64  40  3531350D 0A0D0A00 00158700 00002056  515..... ...... V
80  50  50545231 50324134 33323235 39303846  PTR1P2A4 3225908F
96  60  41524553 52434147 46415242 54334130  ARESRCAG FARBT3A0
112  70  30333441 44535230 30304630 30303131  034ADSR0 00F00011

This is what I get from the current code:

0   0  3C686561 643E0A3C 7469746C 653E4572  <head>.< title>Er
16  10  726F7220 72657370 6F6E7365 3C2F7469  ror resp onse</ti
32  20  746C653E 0A3C2F68 6561643E 0A3C626F  tle>.</h ead>.<bo
48  30  64793E0A 3C68313E 4572726F 72207265  dy>.<h1> Error re
64  40  73706F6E 73653C2F 68313E0A 3C703E45  sponse</ h1>.<p>E
80  50  72726F72 20636F64 65203430 302E0A3C  rror cod e 400..<
96  60  703E4D65 73736167 653A2042 61642072  p>Messag e: Bad r
112  70  65717565 73742073 796E7461 78202827  equest s yntax ('

And this is current code:

my_settings = {
    'ALLOW_UNKNOWN':'True',
    'MONGO_HOST':'localhost',
    'MONGO_PORT':27017,
    'MONGO_DBNAME':'mydb',
    'DOMAIN': {'pnr': {}},
    'RESOURCE_METHODS': ['GET', 'POST'],
    'X-HTTP-Method-Override':'PATCH',
    'XML':'False',
    'JSON':'True',
    'ITEM_METHODS':['GET','PATCH']
}

from eve import Eve
app = Eve(settings=my_settings)
app.run(host='10.4.113.103')
1

There are 1 answers

0
Fernando On

Eve can answer both in JSON and XML but apparently there is no support for the format you want (http://python-eve.org/features.html#jsonxml).

Anyway True and False are Python values of bool type, they must be written without quotes otherwise Python takes them as strings (and non-empty strings in Python evaluated as booleans have a true value).