Skip to content

Support for web sockets #31

@sughodke

Description

@sughodke

Seems like Websockets are ignored in HAR?

Steps to reproduce

Run create_har.py and navigate to https://echo.websocket.org/.ws

Analysis looks like the following

% poetry run integuru --prompt "send messages on a websocket" --model gpt-4o --generate-code
------------------------Successfully analyzed!!!-------------------------------
└── [master_curl] [node_id: 83ea3e62-803c-48ca-aee4-2c2879c39bec]
        [dynamic_parts: []]
        [extracted_parts: ['None']]
        [curl -X GET -H ':authority: echo.websocket.org' -H ':method: GET' -H ':path: /.ws' -H ':scheme: https' -H 'priority: u=0, i' -H 'upgrade-insecure-requests: 1' 'https://echo.websocket.org/.ws']
--------------Generating code------------
└── [master_curl] [node_id: 83ea3e62-803c-48ca-aee4-2c2879c39bec] [dynamic_parts: []] [extracted_parts: ['None']] [input_variables: None] [curl -X GET -H ':authority: echo.websocket.org' -H ':method: GET' -H ':path: /.ws' -H ':scheme: https' -H 'priority: u=0, i' -H 'upgrade-insecure-requests: 1' 'https://echo.websocket.org/.ws']
Aggregated function calls have been saved to 'generated_code.py'
--------------Generated integration code in generated_code.py!!------------

Incorrectly generated code

import requests

def get_echo_websocket_response(cookie_string):
    url = 'https://echo.websocket.org/.ws'
    headers = {
        'priority': 'u=0, i',
        'upgrade-insecure-requests': '1',
        'Cookie': cookie_string
    }
    response = requests.get(url, headers=headers)
    # Since there are no variables to parse, return an empty dictionary
    return {}

cookie_string = 'key1=value1;key2=value2'

# Convert cookie_string to a dict to retrieve values
cookies_dict = dict(item.split('=') for item in cookie_string.split(';'))

# Retrieve values from cookies_dict if needed
value1 = cookies_dict.get('key1')
value2 = cookies_dict.get('key2')

# Call the function
result = get_echo_websocket_response(cookie_string)

print(result)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions