Hi, I wonder if anybody can help me out with a Protobuf parsing issue I'm 
currently facing. So I've implemented the following protobuf based protocol
message singleConfig { 
  string configName = 1;
  string configValue = 2; 
} 

message currentConfig { 
  repeated singleConfig conf = 1; 
} 

message HttpRequest {
  string osVersion = 1;
  string productVersion = 2;
 currentConfig config = 3; 
} 

I send this object HttpRequest, on the body of post http request from the 
c++ based client using the following serialization: 

protocol::ProtocolRequest &requestBody;

// fill up the protobuf object  

req.body() = requestBody.SerializeAsString();

On my http python server, I expect to get http post requests from body that 
conform this protocol.

So upon incoming http post request, the body contents arrived and seems 
valid (I can identify the fields' values from the text)
b'2@\n\x0611.5.1\x12\x061.0(1)\x1a.\n,\n\x08file.json\x12 
ecf1c21c77a419f8f7dbfb714a806166' 

Here's the code that parse the http request. notice 
that ParseFromString accept 'bytes' formatted input. The parsing finish 
without any exception so I assume it went alright...
message = HttpRequest() 
message.ParseFromString(data) 

However, an attempt to access each one of the fields in the protobuf 
structure reveals empty value :
message.osVersion 
''
message.productVersion 

''

...

Any idea what's wrong with the parsing, is it the fact that I'm using 
python3? bad formatting ? should I pass the body not as a string but from 
different encoding ?
Thanks !

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/760e7e07-15c5-42db-84ef-a20564f5481bn%40googlegroups.com.

Reply via email to