w3c / w3c/css-validator

POST requests not properly handled

Open
#227 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
250
Forks
123
PR merge metrics
No merged PRs in 30d

Description

I have a collection of CSS code to be validated and was sending GET requests with url encoded code as a text query parameter. For a large fraction of them, it was successful, but sometimes validation threw an error since the text was too long to be handled by GET. So, I've tried to send POST requests with the following variables in Python:

import requests

URL = 'http://localhost:8080/css-validator/validator'
HEADERS = {'Content-Type': 'text/css; charset=utf-8'}
PARAMS = {
  'output': 'json',
  'warning': 2,
  'profile': 'css3svg'
}
code = 'STRING_OF_CSS_CODE'

resp = requests.post(URL, headers=HEADERS, params=PARAMS, data=code)
print(resp.content) # resp.json() returns a parsing error

, which returned HTML outputs even though json was given. Parsing HTMLs itself is not a problem, but having an HTML output against the json parameter given seems like an unexpected result for the users. Or, if the way I've tried with is incorrect in sending a POST request and there is some documentation about it, that would be very informational.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Python POST request against /css-validator/validator with output=json and compare the response format. Trace how the endpoint handles POST bodies and the output parameter; done means valid CSS submitted by POST returns JSON when requested, or the supported request format is documented clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.