Bring HTTP lib up to spec (wasn't sending carriage returns properly - now does)
This commit is contained in:
		
							parent
							
								
									3ae5ac5be9
								
							
						
					
					
						commit
						21d686fb87
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -28,13 +28,13 @@ std::string & HTTP::Parser::BuildRequest(){
 | 
				
			||||||
  /// \todo Include GET/POST variable parsing?
 | 
					  /// \todo Include GET/POST variable parsing?
 | 
				
			||||||
  std::map<std::string, std::string>::iterator it;
 | 
					  std::map<std::string, std::string>::iterator it;
 | 
				
			||||||
  if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";}
 | 
					  if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";}
 | 
				
			||||||
  builder = method+" "+url+" "+protocol+"\n";
 | 
					  builder = method+" "+url+" "+protocol+"\r\n";
 | 
				
			||||||
  for (it=headers.begin(); it != headers.end(); it++){
 | 
					  for (it=headers.begin(); it != headers.end(); it++){
 | 
				
			||||||
    if ((*it).first != "" && (*it).second != ""){
 | 
					    if ((*it).first != "" && (*it).second != ""){
 | 
				
			||||||
      builder += (*it).first + ": " + (*it).second + "\n";
 | 
					      builder += (*it).first + ": " + (*it).second + "\r\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  builder += "\n" + body;
 | 
					  builder += "\r\n" + body;
 | 
				
			||||||
  return builder;
 | 
					  return builder;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,15 +48,15 @@ std::string & HTTP::Parser::BuildResponse(std::string code, std::string message)
 | 
				
			||||||
  /// \todo Include GET/POST variable parsing?
 | 
					  /// \todo Include GET/POST variable parsing?
 | 
				
			||||||
  std::map<std::string, std::string>::iterator it;
 | 
					  std::map<std::string, std::string>::iterator it;
 | 
				
			||||||
  if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";}
 | 
					  if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";}
 | 
				
			||||||
  builder = protocol+" "+code+" "+message+"\n";
 | 
					  builder = protocol+" "+code+" "+message+"\r\n";
 | 
				
			||||||
  for (it=headers.begin(); it != headers.end(); it++){
 | 
					  for (it=headers.begin(); it != headers.end(); it++){
 | 
				
			||||||
    if ((*it).first != "" && (*it).second != ""){
 | 
					    if ((*it).first != "" && (*it).second != ""){
 | 
				
			||||||
      if ((*it).first != "Content-Length" || (*it).second != "0"){
 | 
					      if ((*it).first != "Content-Length" || (*it).second != "0"){
 | 
				
			||||||
        builder += (*it).first + ": " + (*it).second + "\n";
 | 
					        builder += (*it).first + ": " + (*it).second + "\r\n";
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  builder += "\n";
 | 
					  builder += "\r\n";
 | 
				
			||||||
  builder += body;
 | 
					  builder += body;
 | 
				
			||||||
  return builder;
 | 
					  return builder;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue