Coder Social home page Coder Social logo

anweber / vscode-httpyac Goto Github PK

View Code? Open in Web Editor NEW
207.0 5.0 19.0 4.08 MB

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code

Home Page: https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac

License: MIT License

TypeScript 99.97% Shell 0.03%
rest http postman graphql soap mqtt websocket grpc

vscode-httpyac's Introduction

HttpYac Logo

httpYac - Yet another Client

Quickly and easily send REST, SOAP, GraphQL or gRPC requests directly in Editor

HttpYac HttpYac Extension

Example

@user = doe
@password = 12345678

GET https://httpbin.org/basic-auth/{{user}}/{{password}}
Authorization: Basic {{user}}{{password}}

more examples and guide

Commands

Commands

Name Description
httpyac.send send request in ActiveTextEditor in active line
httpyac.sendAll send all requests in ActiveTextEditor
httpyac.resend resend last request
httpyac.show show cached response of request in ActiveTextEditor in active line
httpyac.viewHeader show response headers, request header and timings of request in ActiveTextEditor in active line
httpyac.save save response of request in ActiveTextEditor in active line
httpyac.clearAll clear all cached responses
httpyac.toggle-env toggle environment of active text document
httpyac.generateCode generate code of request in ActiveTextEditor in active line
httpyac.reset reset environments, oauth sessions and cookies
httpyac.logout see current oauth2 sessions and logout
httpyac.removeCookies remove received cookies
httpyac.new create empty http file
httpyac.showHistory show response history
httpyac.clearHistory clear response history
httpyac.removeHistory remove history entry

Keybindings

keybindings are only active in files with language http

Name Description keybindings
httpyac.send send request in ActiveTextEditor in active line ctrl+alt+r
httpyac.resend resend last request ctrl+alt+l
httpyac.toggle-env toggle environment of active text document ctrl+alt+e

Settings

Request Settings

Name Description Default
httpyac.requestDefaultHeaders default request headers if not overwritten { "User-Agent": "httpyac"}
httpyac.requestGotOptions request options used for got -
httpyac.cookieJarEnabled is CookieJar support enabled true or options

HttpYac extension uses the proxy settings of Visual Studio Code (http.proxy).

Environment Settings

Name Description Default
httpyac.environmentSelectedOnStart list of selected environments on startup -
httpyac.environmentPickMany allow picking many environments at the same time true
httpyac.environmentVariables environment variables { "$shared":{} }
httpyac.envDirName relative or absolute path to folder with dotenv files "env"

Response View Settings

Name Description Default
httpyac.responseViewHeader headers (e.g. content-type), test results (e.g. tests.failed), timings (e.g. timings.total) and meta data (e.g. meta.size) visible in code lens of response [ "timings.total", "content-type", "content-length" ]
httpyac.responseViewMode response view mode of file preview
httpyac.responseViewPrettyPrint response view pretty prints content. Pretty print is only working, if editor receives focus (vscode limitation) true
httpyac.responseViewPreserveFocus response view will not take focus after receiving response true
httpyac.responseViewColumn response preview column option (current, beside) beside
httpyac.responseViewLanguageMap mimetype to languageId map for response view (only used if not in preview mode) beside

httpYac Extension

Name Description Default
httpyac.showGutterIcon show gutter icon to highlight request lines true
httpyac.showNotificationPopup show information, warning and error notifiation message true
httpyac.useMethodInSendCodeLens use request method in send code lens false
httpyac.logLevel log level of output channel warn
httpyac.maxHistoryItems number of max history items 50

License

MIT License

Change Log

See CHANGELOG here

vscode-httpyac's People

Contributors

anweber avatar attilagyongyosi avatar brammanuel avatar bugybunny avatar dependabot[bot] avatar fredrikhr avatar hariprasadiit avatar vojta7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-httpyac's Issues

env files and variables are not correctly resolved

Hello!

Here's the list of few found issues related to dotenv feature:

  1. For some reason env files with names like .env.local, .env.production are not properly handled, it is possible to select .local from the list, but variables are not available within script. In the same time local.env works fine.

first_case_screenshot

# cat .env.local
TEST=this_is_a_test_value

Additional question: how to log all available variables?

  1. Files within env directory is not visible in the list of available environments. Structure is:
|__specs
  |__env
    |__.env.local
    |__local.env
  |__requests.http
  1. The editor shows variables from env as missing ones (red underline).

third_case_screenshot

Probably it will be good to have environment name to be set as a global variable, at least it gives an option to use dotenv-like packages.

Also at the moment it almost impossible to create Postman-like directory structure (or I could not figure out how):

|__specs
  |__env
    |__local.env
    |__staging.env
    |__production.env
  |__api
    |__user
      |__auth.http
      |__profile.http
    |__messages
      |__index.http
      |__create.http
      |__update.http
      |__destroy.http 

Configuration:

VSCodium
Version: 1.58.0
Commit: 2d23c42a936db1c7b3b06f918cde29561cc47cd6
Date: 2021-07-11T00:18:10.593Z (2 days ago)
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Darwin x64 20.5.0

httpYac - Rest Client
anweber.vscode-httpyac
anweber
v2.16.1

Httpyac: Dotenv Dirname = env
Httpyac: Dotenv Enabled = true
Httpyac: Dotenv Variable Provider Enabled = true
Httpyac: Environment Pick Many = true

input box closes on vscode losing focus

Thanks for the awesome extension and library.

I've found that input box closes if the focus is lost. I think in most of the cases either user enters the value or may want to copy paste the value. This behaviour is not ideal for the copy/paste case.

I think it's better to wait for the user to close the input box explicitly.

We can achieve this by passing ignoreFocusOut?: boolean; flag to the vscode's inputbox

requestGotOptions not working as expected

I'm unable to make requests against my local dev environment without a proper certificate.
I always get RequestError - unable to verify the first certificate.
This doesn't happen with the CLI, only through the extension.

I tried updating the requestGotOptions to set rejectUnauthorized to false. But that doesn't seem to work.
The type of requestGotOptions is also set as objct instead of object. But I'm not sure if that is the issue or not.

Incorrect result document type inferred

It seems like httpyac is not always using the content type of responses, which means that the responses are not pretty printed correctly.

  • If I call an endpoint /foo which returns json (content type application/json), the response is correctly formatted. I can see from the breadcrumb that the file is named xxx.json (where xxx is the name of the request -- ### xxx)
  • If I call an endpoint /foo.svc which returns content type text/xml, the response file is named xxx.svc and is not formatted as XML; vscode has Plain Text as the language
  • If I call an endpoint /foo which returns content type application/soap+xml, the response file is actually named foo.json with language type JSON.

Can the extension be smarter about determining the type of the response, so that vscode formats it correctly?

Make timings & meta info easier to review

Both of those pieces of information are available (thank you), but are difficult to access for responses with large bodies. Currently, to review this, one has to open the request info pane and scroll past the response body (however long it might be).

Suggestion

  1. add timing and meta to hover preview,
  2. and/or move them (and perhaps test results too for consistency) above the response body when opening the request info pane.

Pretty Print only works on "httpyac.responseViewContent": "body"

Pretty print is only working in responseViewContent body. exchange only formats body if json is used. Provider auto formatting for other types of body like. rest-client is using pretty-data for formatting.

Discussed in #55

Originally posted by chrismalek July 20, 2021
Hello,

First thanks for all the work on this. This is really a stellar plugin.

I have been watching httpyac closely. I used rest client all day everyday. However, I like some of the subtle features of httpyac and have been wanting to switch over..

I tried to make a switch today to httpyac but the pretty print only seems to work with this setting.

{
"httpyac.responseViewContent": "body"
}

I prefer this setting when debugging APIs however the pretty print does not seem to work. Is that a bug or a "feature"?

{
"httpyac.responseViewContent": "exchange"
}

```</div>

ReferenceError: variable not defined

On vscode with httpyac versions 4.4.0 and 4.5.0, running the first block works, but running the second one throws an error: ReferenceError: user not defined.

Going back to httpyac version 4.3.0, allows me to run the same with the variables interpolated as expected.

{{
    exports.user = "user",
    exports.password = "password"
}}
GET /?test={{user}}

### Auth
POST /login
Content-Type: application/json

{
    "email": "{{ user }}",
    "password": "{{ password }}"
}

{{
    exports.user_id = response.parsedBody.user_id;
}}

Extension for error handling

Is there a way to create an extension that could handle error code with some custom logic? My idea is to create extension that will refresh JWT token every time the 403 gets returned from api. But i'm not sure if that's even possible right now

ReferenceError: sth is not defined

I've wrote sth like this:

### regenerate invoice
@invoiceId = 21060216492001061854

PUT {{host}}/v1/electronicInvoice/regenerate?invoiceId={{invoiceId}}

the 'host' variable is defined in a env file, and I defined invoiceId in current region. When I attempt to send a http request, I got errors. The trace followings:

ReferenceError: invoiceId is not defined
    at Object.userJS (d:\apis\gtc\einvoice.http:12:92)
    at Object.<anonymous> (c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:37177)
    at Generator.next (<anonymous>)
    at c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:36182
    at new Promise (<anonymous>)
    at s (c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:35927)
    at Object.g (c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:36461)
    at t.JavascriptVariableReplacer.<anonymous> (c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:140016)
    at Generator.next (<anonymous>)
    at s (c:\Users\jingc\.vscode-oss\extensions\anweber.vscode-httpyac-2.12.4\dist\extension.js:292:139204)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

Default comment behavior incorrect in script blocks

In script blocks the editor shortcut for commenting things out behaves as if the line were http language instead of js.

Expected

{{
  // highlight me, press the keyboard shortcut to comment out -> I was just commented out
}}

Actual

{{
  # highlight me, press the keyboard shortcut to comment out -> I was just commented out as if I were http lang
}}

Syntax highlighting does work as expected however, including for comments (probably recognizes // as comment and # as itself).

global Variable undefined

Discussed in #47

Originally posted by gerukin July 6, 2021
Hi, I'm new to httpyac. I currently use rest-client and Postman. The extension and runner look promising, congrats!, but somehow I cannot make anything work.

I'm using the latest general availability vscode (Mac) and have installed both the cli and the extension. I opened a new folder with just this one file:

@url = http://www.google.com

### Test
{{url}}

Clicking send gets me this:

ERROR: js: exports.$result = (url);
ERROR: ReferenceError - url is not defined
ReferenceError: url is not defined
	at Object.userJS (/Users/gerukin/dev/http-test/test.http:4:86)
	at Object.<anonymous> (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:37501)
	at Generator.next (<anonymous>)
	at /Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:36506
	at new Promise (<anonymous>)
	at s (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:36251)
	at Object.g (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:36785)
	at t.JavascriptVariableReplacer.<anonymous> (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:143455)
	at Generator.next (<anonymous>)
	at /Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:142841
	at new Promise (<anonymous>)
	at r (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:142586)
	at t.JavascriptVariableReplacer.replace (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:143089)
	at Object.<anonymous> (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:46841)
	at Generator.next (<anonymous>)
	at s (/Users/gerukin/.vscode/extensions/anweber.vscode-httpyac-2.18.0/dist/extension.js:587:46333)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)

This works though:

### Test
@url = http://www.google.com
{{url}}

But my understanding is that those variables are in a global scope and should be available to all requests. What am I doing wrong?

Parsed jwt token not available in script after request

I'm trying to access parsed token in script after request like this:

# @name login
# @jwt AccessToken
POST /login

{
    "Login": "{{user}}",
    "Password": "{{password}}"
}

{{
    const vscode = require('vscode');
    vscode.window.showInformationMessage("token: " + login.AccessToken_parsed)
}}

But the login.AccessToken_parsed is undefined in script. In response preview the token is properly parsed

ExtensionHost crashes when uploading files above a certain size

I tried to upload a file with ~ 5-6 MB with a post using the file operator:

<@ ../../file

Maybe the request output to various sources should be truncated?

EntensionHost Log:

<--- Last few GCs ---> [31624:0000539500000000] 58246 ms: Scavenge 204.2 (225.6) -> 204.2 (225.6) MB, 18.4 / 0.0 ms (average mu = 0.987, current mu = 0.791) allocation failure [31624:0000539500000000] 58415 ms: Mark-sweep 300.2 (321.6) -> 288.1 (309.2) MB, 109.7 / 0.0 ms (+ 0.1 ms in 3 steps since start of marking, biggest step 0.1 ms, walltime since start of marking 648 ms) (average mu = 0.956, current mu = 0.856) finalize <--- JS stacktrace ---> FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory 1: 00007FF6182EFE16 node::Buffer::New+45638 2: 00007FF6182F0020 node::OnFatalError+464 3: 00007FF61AC99623 v8::CFunctionInfo::ArgumentInfo+803 4: 00007FF61AC9957C v8::CFunctionInfo::ArgumentInfo+636 5: 00007FF61AD6E063 v8::JSHeapConsistency::CheckWrapper+65107 6: 00007FF619912F61 v8::Locker::IsActive+72737 7: 00007FF61796E6D1 cppgc::ProcessHeapStatistics::TotalAllocatedSpace+507921 8: 00007FF61796E23B cppgc::ProcessHeapStatistics::TotalAllocatedSpace+506747 9: 00007FF6199DBC40 v8::Locker::IsActive+895232 10: 00007FF619A06979 v8::Locker::IsActive+1070649 11: 00007FF619AAD91B v8::Locker::IsActive+1754587 12: 00007FF61997EDDF v8::Locker::IsActive+514719 13: 00005395000F32FC

Add the ability to customize the output window

User story
As user would like to be able to configure output window.

In setting i see option Customize Response with options:

  • see only response body
  • see only response headers
  • see response headers and body
  • see request and response headers and body

GRPC includeDirs problem

Hello,

There is a problem of relative path resolution for includeDirs option of GRPC.

I have project in /home/user/work/project1 (linux path) opened in vscode.
In this project i have folder "packages", which contains a lot of proto, example tree:

packages
├── package1
│   ├── some1
│   │   ├── some1.proto
│   │   └── some1_service.proto
│   └── package.json
├── package2
│   ├── entity.proto
│   ├── package.json
│   └── property.proto
├── package3
│   ├── some2_service.proto
│   └── package.json
└── grpc-list.http            <--- this is file, which I use to call grpc, listed bellow

And file grpc-list.http:

proto < ./package1/some1/some1_service.proto
includeDirs: ["./"]

GRPC {{host}}/.../List
{}

File ./package1/some1/some1_service.proto contains import like: import package1/some1/some1.proto

When i execute it, i got an exception:

ERROR: ExecuteHook: protoImport failed
ERROR: Error - ENOENT: no such file or directory, open '/home/user/work/project1/packages/package1/some1/package1/some1/some1.proto'
Error: ENOENT: no such file or directory, open '/home/user/work/project1/packages/package1/some1/package1/some1/some1.proto'

If i try to change includeDirs to "/home/user/work/project1/packages" or "./work/project1/packages" - it will work. But that's quit not an variant coz this is under version control and used by different developers =). It looks like it starts resolving of relative path from the HOME_DIR of the current user instead of project root folder.

Wrong request used

In case of a file with multiple requests and the first line contains the GET call, this one is not always used, but the previously executed one.

GET https://httpbin.org/json

GET https://httpbin.org/anything

Client SSL certs

I know that I can use clientCertificates to specify SSL certs on a per-site basis.

{
    "clientCertificates": {
        "mysite.com": {
            "passphrase": "dmfsklmfml",
            "pfx": "c:/mycert.pfx"
        }
    }
}

I have one .http file for which I'd like to use the same cert for all requests, regardless of site. Looking at the docs, I thought that this would work:

{
    "request": {
        "https": {
            "passphrase": "dmfsklmfml",
            "pfx": "c:/mycert.pfx"
        }
    }
}

But when I do that and send a request, the request never returns -- no error, but the notification indicating that a request is in process just stays there until I cancel it.

Am I doing something wrong, or misunderstanding the usage?

POST application/x-www-form-urlencoded and response handler script is broken

Test case:

POST https://httpbin.org/anything
Content-Type: application/x-www-form-urlencoded
accept: application/json

[email protected]&password=pass

> {% client.global.set("email", response.body.form.email); %}

Actual result:

{
...
  "form": {
    "email": "[email protected]",
    "password": "pass\n\n> {% client.global.set(\"email\", response.body.form.email); %}"
  },
...
}

Expected result:

{
...
  "form": {
    "email": "[email protected]",
    "password": "pass"
  },
...
}

"Generate Code" not work.

extension version: v3.1.0
operating system: mac os
problem:
I clicked the "Generate Code" command in the right click popup menu, after choosing the target template(e.g. Shell - cURL), nothing happened except a quickly flashed process notify.

Start new Region if Request is in RFC2616 Format

Start new Http Region if Request is in RFC2616 Format. example.

GET http://www.google.de

GET http:///www.httpbin.org

All Content between these 2 Request Lines belongs to Request 1 (Scripts, MetaParams, ...)

Variable in default header settings

I'd like to use default header in my workspace settings like that: "Authorization": "Bearer {{access_token}}", but unfortunetely the variable isn't picked up here. Is there a way around that?

Use of .httpyac.json

Really like some of the things you're doing with this extension!

I've got an .httpyac.json file that looks like this:

{
    "environments": {
        "$shared": {
            "variables": {
                "host": "www.example.com"
            }
        }
    }
}

I've tried putting this file next to my .http file, in the workspace root, in the .vscode folder, and in the env folder -- but my .http file isn't picking up the host variable. Where is this file supposed to go?

(As a side note, it would be nice if I could hover over variables in the .http file to see the resolved value, or an error if the variable can't be found. Currently, I have to submit the request and see the resulting error to suss out any problems.)

Problem with oauth variables

I'm using oauth2 with a service that requires an extra header with the request (not with the token request, with the actual data request).

@oauth2_clientId = mdfsflsmklf
@oauth2_clientSecret = sdlfmsdklfm
@oauth2_tokenEndpoint = https://www.example.com/v1/token
@oauth2_scope = some-api

GET https://othersite.com/data
client-id: {{oauth2_clientId}}
Authorization: oauth2

The oauth2 request works just fine and gets a token. But the data request does not replace the indicated variable and sends the header as client-id: {{oauth2_clientId}}

The same thing happens if I use some prefix other than oauth2. In order for this to work, I need to add another variable which duplicates the value of oauth2_clientId.

root folder determination

In the extension it seems that the httpyac root folder is always assumed to be vscode's root folder. So the extension looks for an env folder, or a package.json with httpyac key, or a .httpyac.json file there. I think this works fine in a lot of cases but it may break down in a few (ex: monorepo or strict hierarchical structure).

Example

I recently tried something like this:

|__ tests
   |__ http
      |__ env
      |  |__ .env
      |__ requests
      |  |__ something.http
      |__ package.json

In this structure, it seems the CLI will have no issues if run from /tests/http as it will assume this is its root folder (I think), but vscode will only look in its own project root so that the options have to be configured there:

|__ tests
|  |__ ...
|__ .httpyac.json

Personally I would prefer to keep everything in the /tests/http folder in this case.

Suggestion

This works but if at all possible, it would be nice to do something like this for vscode:

  1. look into the current folder for config settings and defaults
  2. if not found, look one folder up
  3. until reaching vscode's project root (and then give up)

I realize this may be confusing to the extension if we have something like this:

|__ monorepo
   |__ tests1
      |__ env
      |  |__ .env
      |__ requests
      |__ .httpyac.json
   |__ tests2
      |__ env
      |  |__ .env
      |__ requests
      |__ .httpyac.json

When running something from tests1 no problem.. tests1's settings will apply, but then when running something from tests2 perhaps vscode-httpyac will not be sure what to do (which environments to show and/or apply). If it is possible to namespace and fully isolate when 2 or more configs are found this would be my preference, so that anything from tests1 is invisible to tests2... and when looking at a file in tests2 nothing from tests1 one shows or applies.

support of vscode-restclient style GraphQL

I tried the GraphQL with the extension exactly the same way as by vscode-restclient:

POST {{server}}
Content-Type: application/json
X-REQUEST-TYPE: GraphQL

query {
	test(id: 95, url: "/test95") { Url Name }
}

but got an error message, that the json is incorrect. Could you please show an working sample of GraphQL querying with the extension?

P.S. I used the extension version 1.6.0 on vscode 1.53.0 on windows

External scripts not updated

External scripts seem to be cached and require restarting vscode to run the updated code.

Example

# in request.http
{{
  // ...
  require('external.js').is({ test, response })
}}
// external.js
// ...

module.exports.is = ({ test, response }) => {
  test('Test name', function () {
    // ...
  })
}
// external.js - after some edits
// ...
  test("Test name - I was just edited yet this won't show", function () {
// ...

Hitting send from vscode the first time will show Test name. Hitting send after the edit will still show Test name. Restarting vscode is enough to see the updated code right away. The script in request.http itself is always updated right away (no caching? - no restart needed).

Bonus :)

// external.js
console.log('Good luck making me show in the ScriptConsole - ever')
# in request.http
console.log('I always show just fine 🎉')

The CLI shows all console logs.

Generate code doesn't work if there are query parameters

When I choose Generate code for a request containing a query parameter it fails with this error:
HARError: validation failed
Version 2.3.0

It doesn't matter what is the target platform generate it for
Example

GET http://abc.com/a?b=c

ERROR: http://abc.com/a?b=c
{
"url": "http://abc.com/a?b=c",
"method": "GET",
"http2": true,
"headers": {
"User-Agent": "httpyac"
},
"cookieJar": {
"version": "[email protected]",
"storeType": "c",
"rejectPublicSuffixes": true,
"cookies": []
},
"followRedirect": true
}
ERROR: HARError - validation failed
HARError: validation failed

console.log output?

I've added a script with console.log But I see output neither in OUTPUT nor in DEBUG CONSOLE So I'm wondering where I could find the script console output ?

image
image

Generate Code made a request

extension version: 4.0.2
vscodium version: 1.60.2
Generate code won't make request in previous versions. In this version, it does.

Session cookies cleared when http file is edited

I have an API that I regularly use that requires a login. The login returns session cookies which need to be passed on subsequent requests.

If I have a file with two requests, one to login and one to retrieve some data. I can run both requests (Send All) or run each individually and it all works well. If after sending my login request I edit the .http file the session cookies are cleared.

I would like to be able to tweak my requests in the http file without having to send my login request every time that I do. I don't remember encountering this when I first started to use the VSCode extension some months ago.

Extension for pm. sandbox

We are currently prototyping a conversion of our PostMan collections to *.http files. We use a lot of pre-request and test scripts. In these scripts we especially use pm.environment.* pm.response.* pm.sendRequest pm.visualizer and, for various reasons, we would like to keep the scripts unmodified for now.

We are wondering if it should be possible to implement an extension to provide a compatible pm object?

Would you be interested to provide such a pm compatibility layer and/or to include it if we would provide it with a PR?

responseViewPreview not working for json

I have setting "httpyac.responseViewPreview": true and it's working fine for plain text response, but whenever the resulting type is application/json - the tab seems to be "normal" instead of preview (and it displays confirmation popup whenever i try to close it)

image

Support for IntelliJ-style http-client.env.json environment files

httpyac supports the .http files used by the IntelliJ HTTP Client, however, it does not support the IntelliJ way of defining environments. Being able to use a http-client.env.json file for environments would be great for cross IDE compatibility.

Example http-client.env.json file

{
  "dev": {
    "host": "https://myhost.dev"
  },
  "qa": {
    "host": "https://myhost.qa"
  },
  "prod": {
    "host": "https://myhost.prod"
  }
}

The example file above should be parsed into three distinct environments named dev, qa and prod.

Is this a feature you also would like to support? If you need support on development, I'll gladly offer some 👍

How to parse the response json file, then set the value to a variable?

i want to following steps

  1. login with username and password
  2. then parse the json body in response, and set it to a variable like 'harbor_auth_token'
  3. use the variable send another request

first step response like this

{
  "token": "AuUefgg",
  "access_token": "",
  "expires_in": 1800,
  "issued_at": "2021-07-29T04:56:53Z"
}

example.http file like this

### login get token
GET https://{{harborHost}}/service/token?account={{harborUsername}}&service=harbor-registry
Authorization: Basic {{harborUsername}}:{{harborPassword}}
Accept: application/json

> {% 
    client.global.set("harbor_auth_token", response.body.json.token); 
    console.log(response.body.json.token); 
%}

### get repositories
GET https://{{harborHost}}/api/v2.0/projects/3/repositories
Authorization: Bearer {{harbor_auth_token}}
Accept: application/json

then i push the "send all", but got an error

TypeError: Cannot read property 'token' of undefined
	at Object.userJS (/Users/ws/workspace/quickapp/QuickAppServer/quickapp-server/src/test/http/test/harbor.http:7:143)
	at Object.<anonymous> (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:37658)
	at Generator.next (<anonymous>)
	at /Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:36665
	at new Promise (<anonymous>)
	at s (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:36410)
	at Object.y [as executeScript] (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:36934)
	at t.IntellijAction.<anonymous> (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:35111)
	at Generator.next (<anonymous>)
	at /Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:34475
	at new Promise (<anonymous>)
	at s (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:34220)
	at t.IntellijAction.process (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:34725)
	at /Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:128005
	at Generator.next (<anonymous>)
	at s (/Users/ws/.vscode/extensions/anweber.vscode-httpyac-2.21.1/dist/extension.js:511:125859)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)

how could i modify the right .http file?

How to Disable SSL Verification?

When i send the request by httpYac

GET https://172.16.18.215/v3/project/c-8tk2p:p-7p2kb/workloads
Authorization: Bearer token-yyyy:xxxxxx...
Accept: application/json

Because that i have used a self issued certificate for inner https server, i got an error as below:

RequestError - unable to verify the first certificate => Disable SSL Verification could fix the problem (# @noRejectUnauthorized or use settings httpyac.requestGotOptions)

Please tell me how to set httpyac.requestGotOptions?
Thanks!

Feature request: Better visibility of environment

It would be nice if the current environment were more visible than in the CodeLens at the top of the file. 

I often have multiple requests in a file, and if I've scrolled down to one lower in the file, the name of the current file is not visible; I have to scroll to the top to check it and change it if needed. Even with just a single request in a file, the fact that CodeLens text is smaller and lighter makes it hard to see.

Being able to see and change this value from someplace like the status bar would be helpful.

Error bubles when the request successfully completed

Build 1.16.0

Test case:

###First request
GET https://httpbin.org/get?test={{test}}

###Second request
GET https://httpbin.org/get?test={{$randomInt}}

Actual result:
Steps:

  1. Run "First request" and see error buble "ReferenceError: test is not defined at Object.userJS" and no response window.
  2. Run "Second request". Error buble hides and show request process. When request finished i see error buble "ReferenceError: test is not defined at Object.userJS" and correct response window.

Peek 2021-03-01 11-58

Expected result:
Run "Second request" not bubles error

Feature Request: File scope variables

Hey, I'm using httpyac for a while. I wonder if there is a way to define variables in one http file.
Here is the outline from rest client with file scope variables:
image

In httpyac, I got outline like this:
image

there is no variable va in the second request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.