I'm writing a program that creates the HTTP Request and sends i securely using SSL. It uses the python library SOCKET to send/receive data. The issue I'm having is that I'm receiving a 200 status back, but the body is not as expected. I've ran the same URI through POSTMAN with no issues.
Here is the full response in bytes (Bytes on wire are smaller than buffer (4096):
b'HTTP/1.1 200 OK\r\nDate: Wed, 20 May 2020 23:42:55 GMT\r\nServer: Apache\r\nStrict-Transport-Security: max-age=315 36000; includeSubDomains\r\nCache-Control: no-cache="Set-Cookie, Set-Cookie2"\r\nAccept-Ranges: bytes\r\nVary: Accep t-Charset,Accept-Encoding,Accept-Language,Accept\r\nX-Frame-Options: SAMEORIGIN\r\nX-UA-Compatible: IE=edge\r\nTrans fer-Encoding: chunked\r\nContent-Type: application/json\r\n\r\n845\r\n'
I'm expecting JSON data following 845\r\n like i see in my other responses but nothing.
My code for sending the request is:
'''
for i in nic_list:
try:
create_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
bind_addr_socket = create_socket.bind((i, 0))
with socket.create_connection((net_loc, port)) as sock:
with context.wrap_socket(sock, server_hostname=net_loc) as ssock:
parse = urlparse(type)
http_type = 'GET {} HTTP/1.1\r\nHost:{}\r\nAuthorization: Basic {}\r\nX-auth-access-token: {}\r\nX-auth-refresh-token: {}\r\nContent-Type: text/html\r\n\r\n'.format(parse[2], net_loc, creds, access_token, refresh_token)
ssock.sendall(http_type.encode())
response = ssock.recv(4096)
except (socket.gaierror, ValueError) as error:
continue
'''
The http_type variable produces the follow HTML, I've modified the output below for confidentiality:
GET /api/fmc_config/v1/domain/ededededed-e0f2-11e3-8169-6d9ed49edef/policy/accesspolicies/000C29F5-FE9F-0ed3-0000-691
489779138/accessrules/0rffr29F5-FE9F-0ed3-0000-derfrfrfr524550 HTTP/1.1
Host:10.1.1.1
Authorization: Basic cfencklnelfkcnelkfnv=
X-auth-access-token: djeidjkfjrjf-frfjirfj
X-auth-refresh-token: frhfuhrufhrifh-fjrifjrifjirfj
Content-Type: text/html