mirror of
				https://github.com/fumiama/C302.git
				synced 2025-11-04 12:55:07 +09:00 
			
		
		
		
	fix
This commit is contained in:
		
							parent
							
								
									6298cfc645
								
							
						
					
					
						commit
						a2ad48f6cb
					
				
							
								
								
									
										12
									
								
								c302.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								c302.c
									
									
									
									
									
								
							@ -23,7 +23,13 @@ int main(int argc, char **argv) {
 | 
			
		||||
    }
 | 
			
		||||
    srand(time(NULL));
 | 
			
		||||
    uint32_t i = rand() % (sizeof(urls)/sizeof(char*));
 | 
			
		||||
    uint32_t len = sizeof(HTTP302HEAD) - 1 + urlsl[i];
 | 
			
		||||
    const struct iovec iov[3] = {{(void *)&len, sizeof(uint32_t)}, {HTTP302HEAD, sizeof(HTTP302HEAD)-1}, {(void *)urls[i], urlsl[i]}};
 | 
			
		||||
    return  writev(1, (const struct iovec *)&iov, 3) != len+sizeof(uint32_t);
 | 
			
		||||
    uint32_t len = sizeof(HTTP302HEAD)-1 + urlsl[i] + 4 + sizeof(CONTENT)-1;
 | 
			
		||||
    const struct iovec iov[5] = {
 | 
			
		||||
        {(void *)&len, sizeof(uint32_t)},
 | 
			
		||||
        {HTTP302HEAD, sizeof(HTTP302HEAD)-1},
 | 
			
		||||
        {(void *)urls[i], urlsl[i]},
 | 
			
		||||
        {"\r\n\r\n", 4},
 | 
			
		||||
        {CONTENT, sizeof(CONTENT)-1}
 | 
			
		||||
    };
 | 
			
		||||
    return  writev(1, (const struct iovec *)&iov, 5) != len+sizeof(uint32_t);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								c302.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								c302.h
									
									
									
									
									
								
							@ -5,8 +5,12 @@
 | 
			
		||||
 | 
			
		||||
#define SERVER_STRING "Server: C302 by Fumiama/1.0\r\n"
 | 
			
		||||
#define HTTP302 "HTTP/1.1 302 Found\r\n"
 | 
			
		||||
#define CONTENT_TYPE "Content-Type: text/html; charset=utf-8\r\n"
 | 
			
		||||
#define CONTENT_LENGTH "Content-Length: 11\r\n"
 | 
			
		||||
#define LOCATION "Location: "
 | 
			
		||||
#define HTTP302HEAD HTTP302 SERVER_STRING LOCATION
 | 
			
		||||
#define HTTP302HEAD HTTP302 SERVER_STRING CONTENT_TYPE CONTENT_LENGTH LOCATION
 | 
			
		||||
 | 
			
		||||
#define CONTENT "<P>Found.\r\n"
 | 
			
		||||
 | 
			
		||||
#define HTTP200 "HTTP/1.0 200 OK\r\n"
 | 
			
		||||
#define H400 "HTTP/1.0 400 BAD REQUEST\r\nContent-Type: text/html\r\n\r\n<P>%s\r\n"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user